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

Harun Reşit Zafer commented on PDFBOX-3749:
-------------------------------------------

No, that's not the issue. I extend the {{PDFTextStripper}} and overwrite the 
{{void writeString(String text, List<TextPosition> textPositions)}}. Normally 
this method is called for each line on the PDF and the {{List<TextPosition> 
textPositions}} parameter includes every letter in the line including the space 
characters. I know they really don't exist in a PDF but {{PDFTextStripper}} 
creates a {{TextPosition}} object for them too. In the {{PDFTextStripper}} this 
method is only called at inside the function {{private void 
writeLine(List<WordWithTextPositions> line)}}. Which supports my assumption. 

Here is how I overwrite this method. 

@Override
protected void writeString(String text, List<TextPosition> textPositions) 
throws IOException {

        //If this method is called per line, I have no problem
       //But for this document it is called per word
        getStyles(textPositions);

        for (TextPosition textPosition : textPositions) {
            output.write(textPosition.getUnicode());
        }
    }



> void writeString(String text, List<TextPosition> textPositions) is not called 
> per line
> --------------------------------------------------------------------------------------
>
>                 Key: PDFBOX-3749
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-3749
>             Project: PDFBox
>          Issue Type: Bug
>    Affects Versions: 2.0.4
>         Environment: Windows 10 64-bit
>            Reporter: Harun Reşit Zafer
>            Priority: Minor
>              Labels: extraction, style
>         Attachments: contract_00105_SEDAR-marked-1.png, 
> contract_00105_SEDAR.pdf
>
>
> We overwrote the {{void writeString(String text, List<TextPosition> 
> textPositions)}} method of the {{PDFTextStripper}} to extract additional 
> position and style information from the PDFs. We thought this method would be 
> called per line and the elements of the parameter {{List<TextPosition> 
> textPositions}} would be all the letters, including the spaces in a line. 
> This is indeed the case for thousands of the documents. However, one 
> particular document, this is not the case and the {{textPositions}} contains 
> just the letters of a word and {{writeString}} is called per word. 
> I am not sure if this would be counted as a bug because the final extracted 
> text is not affected. 
> The problematic PDF is attached. 



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to