> On 12 Feb 2016, at 01:25, Peter Prusinowski <[email protected]> wrote:
> 
> Hi,
> 
> I like to generate multiple PDF documents with images and text. I am using a 
> TTF font and my goal is to load the font once in the constructor of my class 
> and then to create multiple documents with this font.
> 
> I try to load the font with "PDType0Font.load(new PDDocument(), File)" and 
> then call my method three times to create three identical documents.
> The first document is created successful, but the next throwing 
> "java.io.IOException: The TrueType font does not contain a 'cmap' table".
> 
> If I load the font with "PDTrueTypeFont.loadTTF(new PDDocument(), File)", I 
> can create three documents, but only with text.
> Adding an image "PDImageXObject img = LosslessFactory.createFromImage(doc, 
> bufferedImage)" ends up with throwing "java.io.IOException: Scratch file 
> already closed".
> 
> Is it possible to load the font only once at all ?

Each PD object represents something in an individual PDF file, so they can't be 
shared across files. But you can load the font file only once using FontBox's 
TrueTypeFont and then pass that to multiple PDTrueTypeFont constructors.

-- John

> I am using PDFBox 2.0.0-RC3 and here is a code snippet 
> http://pastebin.com/wrvUrZJR
> 
> Thank you.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
> 

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

Reply via email to