Saving merged .doc to .pdf with restrictions

Hi everybody,

I wanted to ask if it is possible to create a .pdf file with restrictions from a mail-merged .doc template.

I would want the user to be able to only open/read the file and print it, blocking any other kind of modifications.

I’ve tried the following snippet:

PdfSaveOptions pso = new PdfSaveOptions();
pso.setSaveFormat(SaveFormat.PDF);

PdfEncryptionDetails ped = new PdfEncryptionDetails(userPassword, ownerPassword, PdfEncryptionAlgorithm.RC_4_128);
ped.setPermissions(PdfPermissions.DISALLOW_ALL);
ped.setPermissions(PdfPermissions.PRINTING | PdfPermissions.HIGH_RESOLUTION_PRINTING);
pso.setEncryptionDetails(ped);

document.save(baos, pso);

but it would ask for a password when you open the PDF, and this is not what I want.

Is there a way to achive it?

Hi Matteo,


Thanks for your inquiry. I have already answered your query here in this post. Please follow that thread for further proceedings.

That worked, thanks!