Am 09.05.2016 um 02:30 schrieb Ivan Ridao Freitas:
Hi, I'm designing an invoice with PDFBox. The only doubt I have is how to control text overlapping? For example, if one line has a text at (x=10) and another at (x=100), how can I prevent the first text to overlap the second one.
I'm adding text with:
        content.beginText();
        content.newLineAtOffset(x, y);
        content.showText(text);
        content.endText();

I know how to calculate the string width and I could cut it until it fits, but is that the only approach? Should I consider inserting a form field and then set the text to a PDTextField?

What I've seen in PDFs "in the wild" is this:

- save graphics
- rectangle
- set clipping path
- draw your text
- restore graphics


Another strategy, if you want to avoid cutting off, is to use a smaller font if the text gets too large, or a narrow font (Arial narrow).

Tilman

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

Reply via email to