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