Your code looks good.

Does "clearAllFontDescriptors" have access to your current document object?

Does "the resulting file is empty" mean that the file is empty, or that the display is blank?

I don't have further ideas without seeing more of the code, and maybe look at the files with pdfdebugger ... maybe try removing "clearAllFontDescriptors" to see whether there's a problem with your logic.

Tilman

Am 14.04.2017 um 09:37 schrieb Vassallo, Fabio:
Actually I don't save the file: i display it in the screen, and then the user 
can choose to save it or not.
So I currently create a byte[] containing the PDDocument data and I use it to 
display the file:

ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
PDDocument document = ...

<... build the PDF content ...>

try
{
     document.save(outputStream);
     document.close();
     return outputStream.toByteArray();
}
catch(IllegalStateException e)
{
     ...
}

I tried to do this:

try
{
     document.save(outputStream);
     document.close();
     document = PDDocument.load(outputStream.toByteArray());
     clearAllFontDescriptors();
     outputStream = new ByteArrayOutputStream();
     document.save(outputStream);
     document.close();
     return outputStream.toByteArray();
}
catch(IllegalStateException e)
{
     ...
}

Where clearAllFontDescriptors() should perform the cosObj.removeItem(fontName). 
But apparently the PDDocument.load(...) doesn't work as I expected, and the 
resulting file is empty.

Fabio Vassallo
Product Development (CIS)



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to