[ 
https://issues.apache.org/jira/browse/PDFBOX-3617?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15725049#comment-15725049
 ] 

Roman edited comment on PDFBOX-3617 at 12/6/16 10:30 AM:
---------------------------------------------------------

I checked this in 2.0.3, found that code flows in "else" clause on this 
version, so this "workaround" does not come to play. Still, there is a same bug 
on 2.0.3
I updated the description


was (Author: rmakarov):
I checked this in 2.0.3, found that code flows in "else" clause on this 
version, so this "workaround" does not come to play. Still, there is a same bug 
on 2.0.3

> Incorrect font width on verical text
> ------------------------------------
>
>                 Key: PDFBOX-3617
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-3617
>             Project: PDFBox
>          Issue Type: Bug
>    Affects Versions: 1.8.12, 2.0.3
>            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 {
> //in 1.8.12 code flows here
>             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 {
> //in 2.0.3 code flows here, but still, incorrect values are returned
>                 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]

Reply via email to