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?