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

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

@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.

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))

@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.

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.

I hope you got the attachment.

@vkotta,

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

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)

@vkotta,

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

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

@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.

@vkotta,

Your reported issue SIGNATURENET-1794 is now fixed in API version 20.1.