All,
Is it possible to re-use a PDFont object?
We have a situation where we are building many PDFs in a single process
and encountering OOMEs running out of heap space. We are using a "large"
(relatively speaking) TrueType font (ARIALUNI.TTF) whose on-disk
representation is 22 MiB.
We are loading the font into each document like this:
PDType0Font.load(document, inputStream)
This font is only loaded when we get a conversion error into the
standard built-in fonts (we are trying to create the smallest PDF
documents possible for several reasons).
Every OOME stack trace I've seen includes this PDType0Font.load() call,
so I was thinking that maybe we'd load the font a single time on startup
and re-use it for every document which needs it, but I don't see any way
in the API to do such a thing.
Are PDFont objects possible to re-use? Even theoretically? It would be
really great if we could do something like this:
static PDFont bigFont;
static {
bigFont = PDType0Font.load(null, inputStream);
}
public void generateDocument() {
...
PDFont localBigFont = document.addFont(bigFont);
PDPageContentStream content = ...;
content.setFont(lodalBigFont);
...
}
I'm currently using PDFBox v2.0.8 but upgrading to a later version
should not represent too much of a problem.
-chris
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]