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

Glen Peterson commented on PDFBOX-188:
--------------------------------------

I have Russian transliteration working as part of a separate project which may 
one-day be merged into PDFBox if we decide that's the right thing to do.  
Pardon my shameless plug:
https://github.com/GlenKPeterson/PdfLayoutManager

The specific functionality you want is:
com.planbase.pdf.layoutmanager.PdfLayoutMgr.convertJavaStringToWinAnsi()

>From the API docs:
"PDF files are limited to the 217 characters of Windows-1252 which the PDF spec 
calls WinAnsi and Java calls ISO-8859-1. This method transliterates the 
standard Java UTF-16 character representations to their Windows-1252 
equivalents where such translation is possible. Any character (e.g. Kanji) 
which does not have an appropriate substitute in Windows-1252 will be mapped to 
the bullet character (a round dot)."
...
"Romanized substitutions are used for the Cyrillic characters of the modern 
Russian (ru) alphabet according to ISO 9:1995 with the following phonetic 
substitutions: 'Ch' for Ч and 'Shch' for Щ."

Someday PDFBox may support UTF-16 characters, but the PDF spec is such that you 
will probably have to embed a font which you are sure will handle the specific 
characters you want to use.  Most fonts support a limited character set, have 
restrictive copyrights, cost money, or are lacking basic features like bold or 
italic.  Even if PDFBox supported this feature now, you'd have to be very 
careful about how you use it.  This is why I chose transliteration to 
Windows-1252 as a stopgap for my project.

FYI, For testing my transliteration, I used the Russian National Anthem which 
is available here:
http://en.wikipedia.org/wiki/National_Anthem_of_Russia#Official_lyrics

I was only vaguely aware of Cyrillic characters before this project and the 
only Russian word I know is "Vodka" and I probably don't even pronounce it 
right.  Feedback from someone who actually speaks the language would be 
extremely helpful!

Please report any issues on the GitHub project.
                
> 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

Reply via email to