[
https://issues.apache.org/jira/browse/PDFBOX-3617?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Roman updated PDFBOX-3617:
--------------------------
Description:
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}
was:
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}
> 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]