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

Leo commented on PDFBOX-3175:
-----------------------------

Commit 1722375 almost fixes the issue with getHeight(), the returned height is 
exactly 1/2 of the actual. The offending lines left in PDFTextStreamEngine are:

// 1/2 the bbox is used as the height todo: why?
float glyphHeight = bbox.getHeight() / 2;

Removing the division by 2 makes call to TextPosition almost identical to 1.8 
style behavior. The only difference I notice, is that the height is also 
adjusted by Font descent (previously, the top left corner of the glyph box had 
to be calculated as: pos = y - getHeight() + (fontDescent * fontSize * 0.001; 
now: pos = y - getHeight());).

> PDFTextStreamEngine probably miscalculates text height
> ------------------------------------------------------
>
>                 Key: PDFBOX-3175
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-3175
>             Project: PDFBox
>          Issue Type: Bug
>          Components: Text extraction
>    Affects Versions: 2.0.0
>            Reporter: Leo
>         Attachments: MarketT_140815-1-marked-1-18.png, 
> MarketT_140815-1-marked-1.png, PDFBOX-3175-reduced.pdf, snapshot.png
>
>
> When parsing a PDF document, TextPosition is created with constant text 
> height, about 2 time smaller than character width, regardless of font size.
> The following workaround to calculate dyDisplay fixes the issue:
>         float verticalScaling = 1/1000f;
>         if (font instanceof PDType3Font) {
>             Matrix fontMatrix = font.getFontMatrix();
>             verticalScaling = fontMatrix.getValue(1, 1);
>         }
>         float dyDisplay = bbox.getHeight() * fontSize * verticalScaling;



--
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