You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Tilman Hausherr (JIRA)" <ji...@apache.org> on 2016/12/05 17:53:58 UTC
[jira] [Closed] (PDFBOX-3617) Incorrect font width on verical text
[ https://issues.apache.org/jira/browse/PDFBOX-3617?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Tilman Hausherr closed PDFBOX-3617.
-----------------------------------
Resolution: Invalid
> 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
> 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: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org