You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Tiruppathi Rajan Gunaseelan (JIRA)" <ji...@apache.org> on 2016/03/17 21:23:33 UTC

[jira] [Commented] (PDFBOX-1705) can not Write Hebrew and Chinese word into a PDF

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

Tiruppathi Rajan Gunaseelan commented on PDFBOX-1705:
-----------------------------------------------------

Hi,

I am unable to write Chinese content into a PDF using your attached EmbeddedFonts.java. Later I found way to fix it by feeding in the "arialuni.ttf" instead of LiberationSans-Regular.ttf in your example. I had confirmed the Chinese PDF generation by writing a hardcoded Chinese data in my example. Later I had extended this piece of logic to write the desired PDF in my application but got into "java.lang.IllegalArgumentException: U+008A is not available in this font's encoding: WinAnsiEncoding". Please advise.

1. From my application, i call an external Webservice and that returns the Chinese + English content in response as a String,
2. I read this response string using UTF-8 as the Charset and unmarshal it to Java bean using JAXRB.
3. To the contentStream.drawString() i passed the string calling the getter method on the pojo which has Chinese data stored in a String variable. This is where i am getting the above exception. Please help me to fix this.

I am using PDFBox version 2.0.0.-RC3. Your help is much appreciated.

Regards,
Tiru

> can not Write Hebrew and Chinese word into a PDF 
> -------------------------------------------------
>
>                 Key: PDFBOX-1705
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-1705
>             Project: PDFBox
>          Issue Type: Bug
>          Components: Writing
>    Affects Versions: 1.8.1
>            Reporter: meiyuanxun
>             Fix For: 2.0.0
>
>
> Can not write Hebrew or Chinese into PDF file. It shows unreadable codes.  If it does not support with latest version, please comments me. Thank you.
> {code}
> PDDocument document = new PDDocument();
> PDPage page = new PDPage();
> document.addPage( page );
> PDFont font = PDTrueTypeFont.loadTTF(document, "pdf/simkai.ttf");
> PDPageContentStream contentStream = new PDPageContentStream(document, page);
> contentStream.beginText();
> contentStream.setFont( font, 12 );
> contentStream.moveTextPositionByAmount( 100, 700 );
> contentStream.drawString("中文 = Chinese");
> contentStream.drawString("Hebrew= העתק");
> contentStream.endText();
> contentStream.close();
> document.save( "pdf/Hello World.pdf");
> document.close();
> {code}



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

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org