You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Ryan Bair <ry...@gmail.com> on 2014/05/23 21:05:02 UTC

Underlining text

I'm attempting to underline some text.

>From what I can see, PDF itself doesn't have too much to offer in the
region. InDesign and other applications seem to simply draw a line
underneath the word. Doing this is a bit of a hassle, but certainly doable
with a little work.

What I don't see is how to determine where the underline should be
positioned relative to the baseline and what the thickness should be.
Peeking around the source I saw that the PostScriptTable class has
getUnderlinePosition and getUnderlineThickness methods to which sound
promising but I can't figure out how to get there from PDTrueTypeFont.

In short, how do I draw underlines?

Thanks

Re: Underlining text

Posted by Ryan Bair <ry...@gmail.com>.
I ended up instantiating my own TTFParser and going from there to get down
to the underline properties as well as the unitsPerEm.

I recorded the positions of the characters that needed to be underlined as
well as the line style to use as I drew them. When I was done with a given
area of the page, I went back and drew the lines that I previously
described.

It was more work than I had hoped for, but the end result looks perfect.


On Fri, May 23, 2014 at 3:05 PM, Ryan Bair <ry...@gmail.com> wrote:

> I'm attempting to underline some text.
>
> From what I can see, PDF itself doesn't have too much to offer in the
> region. InDesign and other applications seem to simply draw a line
> underneath the word. Doing this is a bit of a hassle, but certainly doable
> with a little work.
>
> What I don't see is how to determine where the underline should be
> positioned relative to the baseline and what the thickness should be.
> Peeking around the source I saw that the PostScriptTable class has
> getUnderlinePosition and getUnderlineThickness methods to which sound
> promising but I can't figure out how to get there from PDTrueTypeFont.
>
> In short, how do I draw underlines?
>
> Thanks
>