You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "John Hewson (JIRA)" <ji...@apache.org> on 2014/10/11 02:27:35 UTC

[jira] [Closed] (PDFBOX-1709) processEncodedText gives wrong coordinates

     [ https://issues.apache.org/jira/browse/PDFBOX-1709?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

John Hewson closed PDFBOX-1709.
-------------------------------
    Resolution: Won't Fix

This won't get fixed in 1.8, and I'm still not sure what the exact issue is. In 2.0 we have some new APIs and you can subclass PDFStreamEngine#showGlyph to get per-glyph positioning information.

> processEncodedText gives wrong coordinates
> ------------------------------------------
>
>                 Key: PDFBOX-1709
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-1709
>             Project: PDFBox
>          Issue Type: Bug
>          Components: PDModel
>    Affects Versions: 1.8.2
>         Environment: Windows 7 sp1, Javac 1.6.0_30, Java 1.7.0_17
>            Reporter: Robert Simms
>              Labels: test
>         Attachments: PDFBOX1709-0.pdf, PDFBOX1709-1.pdf, PDFBOX1709-2.pdf
>
>
> PDFStreamEngine#processEncodedText gives x-coord short by width of previous text, for next text at same y-coord.
> ---
> Use this PostScript to create PDFs that demonstrate x-coordinate issue with processEncodedText().
> %!
> /Helvetica findfont 20 scalefont setfont
> 100 72 moveto
> (Hello) show
> % CASES
> %    Uncomment any one of the following, make a PDF (with ghostscript ps2pdf, or acrobat distiller),
> %    then process the PDF with java implementation of PDFBox PDFTextStripper.
> %    listing text and x,y positions obtained by overriding the processEncodedText() method.
> %    For example, the x-coord. of a text item may be printed in that method with
> %       System.out.format("%.2f\n", this.getTextMatrix().getXPosition());
> % % 0. Works to convince processEncodedText that string 'Hello world.' was at 100,72.  This is good.
> %
> % ( world.) show
> % % 1. Does not trick processEncodedText into thinking 'Hello' followed by ' ' + 'world.'
> % %    Instead,
> % %    x-coord. of 'world.' reported as being actual position minus width of 'Hello', plus width of ' '
> % %    which is x=105.56 in this case.
> % 
> %( ) stringwidth pop 0 rmoveto
> %(world.) show
> % % 2. Positioning 'world.' within about 500 points from 'Hello', at same vertical position causes
> % %    processEncodedText to give
> % %    x-coord. of 'world.' as actual position minus width of 'Hello'
> % %    which is x=200 in this case.
> %
> %100 0 rmoveto
> %(world.) show
> showpage



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)