We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to generate a read-only pdf with Aspose.words

Hi,


I am trying to generate a read-only pdf file with Aspose.words for Java, and I found the following article which give the sample code with C#. I couldn’t find the similar classes in Aspose.words for java. Could you show me how to generate a read-only pdf file with Aspose.Words for Java?
Generate ReadOnly Pdf

Thanks
Tony

Hi Tony,


Thanks for your inquiry. Please use following code example to achieve your requirements. Hope this helps you.


Document doc = new Document(MyDir + “in.docx”);<o:p></o:p>

<o:p></o:p>

PdfSaveOptions saveOptions = new PdfSaveOptions();<o:p></o:p>

<o:p></o:p>

// Create encryption details and set owner password.<o:p></o:p>

PdfEncryptionDetails encryptionDetails = new PdfEncryptionDetails("", “password”, PdfEncryptionAlgorithm.RC_4_128);<o:p></o:p>

<o:p></o:p>

// Start by disallowing all permissions.<o:p></o:p>

encryptionDetails.setPermissions(PdfPermissions.DISALLOW_ALL);<o:p></o:p>

saveOptions.setEncryptionDetails(encryptionDetails);<o:p></o:p>

<o:p></o:p>

// Render the document to PDF format with the specified permissions.<o:p></o:p>

doc.save(MyDir + “Out.pdf”, saveOptions);