[
https://issues.apache.org/jira/browse/PDFBOX-188?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13604258#comment-13604258
]
Glen Peterson commented on PDFBOX-188:
--------------------------------------
Oops, yes, I misunderstood. But after thinking about it for a couple days, I
suspect that if the Russian text in the PDF was encoded in Windows-1252/WinAnsi
you could do a reverse mapping based on the code in
com.planbase.pdf.layoutmanager.PdfLayoutMgr.convertJavaStringToWinAnsi() and
get every modern Russian character except for Ч and Щ. I suppose you could do
a look-ahead whenever you encounter a T, C or S to see if it is a Tch or Ch (as
in Tchaikovsky the composer), or Shch and maybe get every character at the
price of some performance.
If the PDF text is encoded in UTF-16BE (Big-Endian), then it's probably a
matter of telling Java the right encoding for internal strings inside PDFBox.
I still don't know whether Java is UTF-16 Big-Endian or Little-Endian
internally, but it shouldn't be hard to look that up, or write a test, and swap
pairs of bytes if necessary. I think Java 7 even has a built in API for
conversions like these. That won't help us in Java 5, but it's nice to know
that Java is going in this direction.
I'll see about my contributor's agreement momentarily.
> doesn't convert properly russian characters
> -------------------------------------------
>
> Key: PDFBOX-188
> URL: https://issues.apache.org/jira/browse/PDFBOX-188
> Project: PDFBox
> Issue Type: Bug
> Components: Text extraction
> Assignee: Andreas Lehmkühler
> Priority: Minor
>
> [imported from SourceForge]
> http://sourceforge.net/tracker/index.php?group_id=78314&atid=552832&aid=1537323
> Originally submitted by amashtakov on 2006-08-09 04:44.
> Hi,
> I've tried to extract text from attached PDF using
> both stable release PDFBox-0.7.2 and recent nightly
> build PDFBox-0.7.3-dev-20060809 and the following code
> snipped:
> // 1. parse document
> PDFParser parser = new PDFParser(is);
> parser.parse();
> cos = parser.getDocument();
> // 2. extract text
> PDFTextStripper stripper = new PDFTextStripper();
> String text = stripper.getText(new PDDocument(cos));
> // 3. dump output
> FileOutputStream os = new FileOutputStream("file.txt");
> OutputStreamWriter ow = new
> OutputStreamWriter(os, "UTF-8");
> ow.write(text);
> ow.flush();
> Despite of russian contents of original PDF, the
> output file doesn't contain any "valid" russian
> character(s).
> I've also tried to convert the same PDF with the
> foolabs-xpdf tool - the output contains valid
> UTF-8 russian text.
> PS: I couldn't attach file because of sourcecforge
> size limit. (the size is ~545K). Is it possible
> to pass it to dev. team ?
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira