Hi,
I’m trying to use Aspose PDF to add DocumentPrivileges to a PDF via the PdfFileSecurity class.
This works with most PDFs, but when I try using PDFs that have been created via MS Word which seems to have other fonts (e.g. Cambria) in them, the conversion seems to fail and returns a 0 byte output stream…
I’ve attached two PDF files I want to add privileges on. The first, Test1.pdf will fail because some text is formatted with the Courier font (a ‘default’ PDF supported font) and some with Calibri/Cambria fonts.
The second PDF, Test2.pdf, is exactly the same, expect now all the text is formatted with Courier font. This second PDF works fine, the output stream returns a new document with privileges added.
Are there some options that I’m missing, looking at the very sparse documentation and the annoyingly obfusticated code I cant see many options on how to deal with fonts when trying to set security privileges on a PDF file.
Code snippet;
PipedOutputStream os = new PipedOutputStream();
PipedInputStream is = new PipedInputStream(os);
InputStream dataStream = myDataObject.dataStream();
Document doc = new Document(dataStream);
//doc.setFontReplaceBehavior(1);
PdfFileSecurity pdfFileSecurity = new PdfFileSecurity(doc, os);
pdfFileSecurity.setPrivilege(DocumentPrivilege.getForbidAll());
pdfFileSecurity.close();
dataStream.close();
os.close();
This looks like a bug with PdfFileSecurity