[
https://issues.apache.org/jira/browse/PDFBOX-3617?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15722867#comment-15722867
]
Tilman Hausherr commented on PDFBOX-3617:
-----------------------------------------
Please don't do this, expect it will work, and then ask for support if it
doesn't:
{code}
Method method = font.getClass().getDeclaredMethod("getDescendantFonts");
method.setAccessible(true);
{code}
That method is private because it's not for you.
getDescendantFonts does not exist in 2.0, so you're using 1.8. That one is
known to have troubles with fonts. Please use 2.0.3. If it doesn't work, open a
new issue. I'm closing this one as invalid.
> Incorrect font width on verical text
> ------------------------------------
>
> Key: PDFBOX-3617
> URL: https://issues.apache.org/jira/browse/PDFBOX-3617
> Project: PDFBox
> Issue Type: Bug
> Reporter: Roman
> Attachments: 6L.pdf
>
>
> On the attached document we are extracting glyph coordinates as shown in code
> snippet below. The "w" variable is used to calculate the width of glyph. It
> is returning wrong value.
> The document contains "........KKKKWWWW!!!!0000" string. For dots it returns
> too big value, but for "K" characters it returns to small value.
> {code}
> public class Extractor extends PDFTextStripper {
> //<...CUT...>
> protected void writePage() throws IOException {
> for (List<TextPosition> textList : charactersByArticle) {
> //charactersByArticle was inherited from base class
> Iterator textIter = textList.iterator();
> //<...CUT...>
> while (textIter.hasNext()) {
> TextPosition position = (TextPosition)
> textIter.next();
> //<...CUT...>
> PDFont font = position.getFont();
> //<...CUT...>
> float w;
> try {
> if (font instanceof PDType0Font && ((PDType0Font)
> font).getDescendantFont() == null) {
> Method method =
> font.getClass().getDeclaredMethod("getDescendantFonts");
> method.setAccessible(true);
> COSArray arr = (COSArray) method.invoke(font);
> w = PDFontFactory.createFont((COSDictionary) ((COSObject)
> arr.get(0)).getObject()).getFontWidth(c);
> } else {
> //NOT going here on attached sample
> w = font.getFontWidth(c);
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]