You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Jian Shen <ji...@live.com> on 2011/09/24 08:21:36 UTC

how to write Chinese characters

    
I am new to PDFBox, and I couldn't figure out how to write Chinese characters to pdf file. With the code snippet below, the result pdf file displays some squares and strange symbols, instead of the correct Chinese character. And Acrobat Reader pops up a message, saying "The font '??' contains bad /Widths." 

            PDFont font = PDTrueTypeFont.loadTTF(document, "C:\\Windows\\fonts\\simkai.ttf");
            PDPageContentStream contentStream = new PDPageContentStream(document, page);
            
            contentStream.beginText();
            contentStream.setFont(font, 12);
            contentStream.moveTextPositionByAmount(100, 700);
            contentStream.drawString("\u59D3");
            contentStream.endText();


What am I missing? Is there a code sample for generating PDF files with Asian characters?


Thanks!
-Jian
 		 	   		  

RE: how to write Chinese characters

Posted by Jian Shen <ji...@live.com>.
That's good to know. I might need to look for an alternative solution. Thank you!

> From: heshamgneady@gmail.com
> To: users@pdfbox.apache.org
> Subject: Re: how to write Chinese characters
> Date: Sat, 24 Sep 2011 08:59:13 +0200
> 
> I guess you mean this :
> https://issues.apache.org/jira/browse/PDFBOX-553
> 
> We are all waiting for this to be fixed.
> 
> 
> Best regards ,
> Hesham
> 
> ---------------------------------------------
> Included message :
> 
> 
> >
> >
> > I am new to PDFBox, and I couldn't figure out how to write Chinese 
> > characters to pdf file. With the code snippet below, the result pdf file 
> > displays some squares and strange symbols, instead of the correct Chinese 
> > character. And Acrobat Reader pops up a message, saying "The font '??' 
> > contains bad /Widths."
> >
> >            PDFont font = PDTrueTypeFont.loadTTF(document, 
> > "C:\\Windows\\fonts\\simkai.ttf");
> >            PDPageContentStream contentStream = new 
> > PDPageContentStream(document, page);
> >
> >            contentStream.beginText();
> >            contentStream.setFont(font, 12);
> >            contentStream.moveTextPositionByAmount(100, 700);
> >            contentStream.drawString("\u59D3");
> >            contentStream.endText();
> >
> >
> > What am I missing? Is there a code sample for generating PDF files with 
> > Asian characters?
> >
> >
> > Thanks!
> > -Jian
> > 
> 
 		 	   		  

Re: how to write Chinese characters

Posted by "Hesham G." <he...@gmail.com>.
I guess you mean this :
https://issues.apache.org/jira/browse/PDFBOX-553

We are all waiting for this to be fixed.


Best regards ,
Hesham

---------------------------------------------
Included message :


>
>
> I am new to PDFBox, and I couldn't figure out how to write Chinese 
> characters to pdf file. With the code snippet below, the result pdf file 
> displays some squares and strange symbols, instead of the correct Chinese 
> character. And Acrobat Reader pops up a message, saying "The font '??' 
> contains bad /Widths."
>
>            PDFont font = PDTrueTypeFont.loadTTF(document, 
> "C:\\Windows\\fonts\\simkai.ttf");
>            PDPageContentStream contentStream = new 
> PDPageContentStream(document, page);
>
>            contentStream.beginText();
>            contentStream.setFont(font, 12);
>            contentStream.moveTextPositionByAmount(100, 700);
>            contentStream.drawString("\u59D3");
>            contentStream.endText();
>
>
> What am I missing? Is there a code sample for generating PDF files with 
> Asian characters?
>
>
> Thanks!
> -Jian
>