Btw I had a similar problem at work, and I use a three step approach:
1. Built-in
2. Liberation Sans
3. Arial Uni
IIRC the Arial Uni font hasn't been used since I made the change to use
Liberation Sans. I did this not because of memory problems but because I
noticed that the texts looked crappy, and the reason were names of
people from EE countries or from Turkey.
Tilman
Am 02.08.2021 um 20:20 schrieb Tilman Hausherr:
You can load fonts like this:
TrueTypeFont ttf = new TTFParser().parse(fontfile);
then use it in different documents like this:
PDFont font = PDType0Font.load(document, ttf, true);
The "font" object can be used across pages in the same document.
don't forget to close "ttf" when done. But this is more a thing about
speed than about space. You should always update before asking
questions, we sometimes manage to improve the memory footprint.
Tilman
Am 02.08.2021 um 15:02 schrieb Christopher Schultz:
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]
---------------------------------------------------------------------
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]