Free Support Forum - groupdocs.com

How to E-Sign pdf document generated using SSRS with images and certifcates stored in a database


#1

Hello, I have a scenario where we generate our reports in SSRS. Depending on the user that signed in to the website, their pfx file(certificate file) and signature file(.png file) are retrieved from the database using entity framework and intialized with signoptions object.
Even though I am using memory streams all over, I am getting an error when I sign the document saying that “access is denied to Data\Output”. I do not understand as to why it needs access to a file server, when I am supplying all the inputs as memory streams and getting the output as memory stream which is a pdf document and will be written back to the browser with Response Object.

Here is the sample code.

Protected Function Signature(pdfFileStream As Stream) As Byte()
Dim config As SignatureConfig = Utilities.GetConfigurations()
config.OutputPath = “Data\Output”
config.StoragePath = “Data\Storage”
'config.ImagesPath = “…\Data\Images”
'config.CertificatesPath = “…\Data\Certificates”
Dim collection = New SignatureOptionsCollection()
Dim handler = New SignatureHandler(config)

    Dim oPE As QCSystem2013.tblPE
    oPE = DbContext.tblPEs.SingleOrDefault(Function(P) P.PERegNo = ddpes.SelectedValue)




    Dim signOptions = New PdfSignDigitalOptions(SerializeToStream(oPE.DigitalCertificate), SerializeToStream(oPE.DigitalSignature))

    Dim lbllocation As Label = New Label()
    lbllocation.Text = "test" & Environment.NewLine & " Corporate Office"
    signOptions.Location = lbllocation.Text
    signOptions.Password = "kandy87"
    signOptions.Left = 500
    signOptions.Top = 350
    signOptions.Width = 300
    signOptions.Height = 380
    signOptions.Margin = New GroupDocs.Signature.Domain.Padding With {
    .Top = 20,
    .Left = 300
}
    Dim oSaveOptions As SaveOptions
    oSaveOptions = New SaveOptions(OutputType.Stream)
    ' handler.
    signOptions.HorizontalAlignment = GroupDocs.Signature.Domain.HorizontalAlignment.Left
    signOptions.DocumentPageNumber = 1
    Dim signedPath As Stream
    Dim b As Byte() = Nothing

    Try
        signedPath = handler.Sign(Of Stream)(pdfFileStream, signOptions)
        Using br As New BinaryReader(signedPath)
            b = br.ReadBytes(signedPath.Length)
        End Using

    Catch ex As Exception
        Dim i As Integer
        i = 9
    End Try


    Return (b)


End Function

End Class


#2

@vkotta,

Thanks for your inquiry. In order to further investigate the issue, we are required following details from you:

  • Which version of the API you are using?
  • Can you please share the problematic file with us?.

Please specify the details and we will be glad to help you.


#4

API Version 18.17.1.0
It can be reproduced with any pdf file as input. we are using a basic pfx file for signing and a signature stamp as an image file. I just want to make sure the API doen’t depend on file system. In my case I get the pdf as bytes() from a SSRS Render method. As an example I loaded(1.pdf) it from local file system.
Public Function SerializeToStream(ByVal o As Byte()) As MemoryStream
Dim stream As MemoryStream = New MemoryStream(o)
Return stream
End Function

Dim fileStream As FileStream = File.OpenRead(“c:\1_files\1.pdf”)
Dim fileContent As Byte() = New Byte(fileStream.Length - 1) {}
fileStream.Read(fileContent, 0, CInt(fileStream.Length))
fileStream.Close()
Signature(SerializeToStream(fileContent))


#5

@vkotta,

In order to further investigate this issue at our end, we need a simple console based application/project using that issue could be reproduced. We’d appreciate your cooperation in this regard.


#6

Hi Sami. I put together a quick web app which signs a single page pdf with the included pfx and image file. it gives an error.


#7

I hope you got the attachment.


#8

@vkotta,

We’re sorry, we didn’t get any attachment.


#9

Lets try it again. I clicked on upload button and attached the file. it says its uploaded but i don’t see the attachment.Code.zip (36.3 KB)


#10

@vkotta,

You may upload your project on some cloud storage (e.g. Dropbox) and share link with us.


#11

Here it is buddy. Its not uploading if its exceeds some size. Unfortunately it doesn’t tell me either.Code.zip (36.3 KB)


#12

@vkotta,

We are investigating this scenario at our end. Your investigation ticket ID is SIGNATURENET-1794. As we have any update on it, we’ll notify you.
Furthermore, we’re still not able to compile the project you have shared earlier. Please upload your complete running project on some cloud storage (e.g. Dropbox) and share link with us.