Thanks for getting back to us.
We have tested the scenario by running shared project and were able to notice the exception while specifying the
FileParams. We have logged an investigation ticket as PDFNET-44598 in our issue tracking system for further investigation. We will look into the details of the scenario and keep you posted in case of any further progress.
Furthermore, we have tried to add File Attachment using
FileAttachmentAnnotation and in this case the
FileParams were added successfully. Please change your
AddAttachmentToDocument() method definition as following and run the project:
Public Sub AddAttachmentToDocument(ByVal document As IO.Stream,
ByVal attachment As IO.Stream,
ByVal attachmentName As String,
ByVal attachmentDescription As String,
ByRef output As IO.Stream)
If document Is Nothing Then Return
Dim PdfDocument As New Aspose.Pdf.Document(document)
Dim PdfAttachment As New Aspose.Pdf.FileSpecification(attachment, attachmentName)
Dim file As New Aspose.Pdf.Annotations.FileAttachmentAnnotation(PdfDocument.Pages(1), New Aspose.Pdf.Rectangle(40, 800, 60, 820), PdfAttachment)
PdfAttachment.Params = New Aspose.Pdf.FileParams(PdfAttachment)
PdfAttachment.Params.CreationDate = DateTime.Now
PdfAttachment.Params.ModDate = DateTime.Now
file.Color = Aspose.Pdf.Color.Transparent
file.Contents = "This is Attachment."
file.Icon = Aspose.Pdf.Annotations.FileIcon.Paperclip
file.Name = "AttachedFile"
'save output document
As shared earlier, the Property
Size is Read-Only because it is specified by the file size of original file added as attachment and you cannot set this with some custom value.