Aspose PDF Java - PdfFileSecurity returns 0 bytes output stream when adding security to PDF

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

Hi Nathan,


Thanks
for using our API’s.<o:p></o:p>

I
have tested the scenario and I am able to notice the same problem. For the sake
of correction, I have logged this problem as PDFNEWJAVA-34034 in
our issue tracking system. We will further look into the details of this
problem and will keep you updated on the status of correction. Please be
patient and spare us little time. We are sorry for this inconvenience.

Thanks for the quick response Nayyer.

Any idea how long this issue will take to resolve?

Do you have a public link to the JIRA so we can follow up on the state of PDFNEWJAVA-34034

Thanks,
Nathan

nemccarthy:
Thanks for the quick response Nayyer.

Any idea how long this issue will take to resolve?
Hi Nathan,

Thanks for your patience.

As we recently have been able to notice this issue, so development team requires little time to investigate and figure out the reasons of this problem. However, as soon as we have made some definite progress towards its resolution, we would be more than happy to update you with the status of correction.

nemccarthy:
Do you have a public link to the JIRA so we can follow up on the state of PDFNEWJAVA-34034
The JIRA is an internal issue management system and I am afraid you might not have an access. Nevertheless, we will keep you posted on the status of correction within this forum thread.