PDF is corrupted on applying the security

Hi,

Please find attached three documents.

  • First document is a source word document (InputDoc.docx)
  • Second document is a PDF document (outputPDF.pdf) which is converted from first document using Aspose words.
  • Third document is another PDF document (output2pdf.pdf) which is from second document using Aspose. PDF.

In our application, we can upload the Word documents & PDF documents and both will be converted to PDF documents and apply security.

We are using the below code to generate the PDF document from words and applying the security.

-----------------------------------------------------------------------------------------------------

var docWord = new Aspose.Words.Document(sourceFilePath);

docWord.Range.UpdateFields();

. . . . . . . . . . . .

var options = new PdfSaveOptions{

SaveFormat = SaveFormat.Pdf,

JpegQuality = 100,

Compliance = PdfCompliance.Pdf15,

PreserveFormFields = false,

TextCompression = PdfTextCompression.Flate,

EmbedFullFonts = true,

EncryptionDetails = new PdfEncryptionDetails("", "XYZ", PdfEncryptionAlgorithm.RC4_128)

};

options.EncryptionDetails.Permissions = PdfPermissions.DisallowAll | PdfPermissions.Printing | PdfPermissions.ContentCopyForAccessibility | PdfPermissions.DocumentAssembly;

docWord.Save(destFinalPath, options);

--------------------------------------------------------------------------------------------------------------------------------------------------------

Below is code to apply the security on the PDF documents

var fileSecurity = new PdfFileSecurity(sourceFilePath, destFinalPath);
DocumentPrivilege privilege = DocumentPrivilege.ScreenReaders;
privilege.AllowAssembly = true;
privilege.AllowPrint = true;
fileSecurity.SetPrivilege(privilege);

The problem here is, the third document which is generated from second Pdf document is getting corrupted.

Can you please check the code and these documents and let us know how we can resolve this issue?

Hi Balaji,

Thanks for using our products. I have tested the scenario using Aspose.Pdf for .NET 6.3.0 and I am unable to notice any problem. Please take a look over the resultant PDF document with applied security restrictions. Can you please try using Aspose.Pdf for .NET 6.3.0 and in case you still face any problem, please feel free to contact. We are really sorry for your inconvenience.

Thanks!!! It is working with Aspose PDF 6.3 version.

We were testing with 6.2 version.