Issue 81 in xdocreport: how can xdocreport supply the Chinese character.

617 views
Skip to first unread message

xdocr...@googlecode.com

unread,
Feb 26, 2012, 5:15:20 AM2/26/12
to xdocr...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 81 by guozwh...@gmail.com: how can xdocreport supply the Chinese
character.
http://code.google.com/p/xdocreport/issues/detail?id=81


i retrieved my older project, i find iText can't supply Chinese words, but
if u add iTextAsian.jar ,it will be ok.

Pls download the accessories .

in the project of accessories, run ReportConfigUtil.java main(), code like
this:
public static void main(String[] args){
//ReportConfigUtil.getReportConfig("/com/dbet/cfg/myreport.xml").test();
ReportData rd = new ReportData();
rd.addParam("nowDate",new Date().toLocaleString())
.addParam("person", "郭州伟")
.addParam("first","2000年01月01日")
.addParam("last","2008年12月31日");
ReportConfig cfg =
ReportConfigUtil.getReportConfig("/com/dbet/cfg/myreport.xml");
ReportFactoryUtil.writePdf("c:/demo.pdf",cfg,rd);
}

it'll create c:/demo.pdf with Chinese charaters.

so i think if xdocreport add iTextAsian.jar, it also can supply Chinese
chararter.

Attachments:
report.zip 1.6 MB

xdocr...@googlecode.com

unread,
Feb 26, 2012, 5:44:33 PM2/26/12
to xdocr...@googlegroups.com
Updates:
Status: Accepted

Comment #1 on issue 81 by angelo.z...@gmail.com: how can xdocreport supply

Hi,

Many thanks for your zip and explanation. Today I have not time to study it.

@Leszek : do you think it's possible for you to study Chinese character
with our ODT converter? I could modify our Docx converter like ODT
converterif you have time to fix this problem.

If it's possible for Leszek, I think Guo, you should attach an ODT and Docx
with Chinese character.

Many thanks

Regards Angelo


xdocr...@googlecode.com

unread,
Mar 1, 2012, 3:14:01 AM3/1/12
to xdocr...@googlegroups.com

Comment #2 on issue 81 by abe...@gmail.com: how can xdocreport supply the
Chinese character.
http://code.google.com/p/xdocreport/issues/detail?id=81

Actually I have no much time to investigate the issue.

Guo - first try to set font encoding. See wiki
http://code.google.com/p/xdocreport/wiki/ODFDOMConverterPDFViaIText
http://code.google.com/p/xdocreport/wiki/ODTReportingJavaMainConverter
how to do this. Maybe this will work??

Also I think that you don't need iTextAsian.jar. Xdocreport converter scans
directories like 'c:/windows/fonts' and should be able to find operating
system fonts.

Regards
Leszek

xdocr...@googlecode.com

unread,
Apr 2, 2012, 11:49:10 AM4/2/12
to xdocr...@googlegroups.com

Comment #3 on issue 81 by angelo.z...@gmail.com: how can xdocreport supply

Hi,

Leszek, I have quicly tested the Chinese docx and it doesn't works. It
seems that with iText you should use embedded character
http://stackoverflow.com/questions/5785775/japanese-chinese-text-in-pdf-using-itext-java

But our converter doesn't support that (how to manage that?) But I think
there is too problem with docx converter to retreives thewell font. For the
moment no time to investigate to the docx converter.

I have added the chinese docx in the JUNit
http://code.google.com/p/xdocreport/source/browse/thirdparties-extension/org.apache.poi.xwpf.converter/src/test/java/org/apache/poi/xwpf/converter/itext/XWPFPOI2PDFViaiTextConverterTest.java
which uses the docx
http://xdocreport.googlecode.com/git/thirdparties-extension/org.apache.poi.xwpf.converter/src/test/resources/org/apache/poi/xwpf/converter/TestChineseCharacters.docx

Guo, if you wish help us to support Chinese character for docx/odt
converter, you are welcome!

Regards Angelo

xdocr...@googlecode.com

unread,
Apr 3, 2012, 4:01:58 AM4/3/12
to xdocr...@googlegroups.com

Comment #4 on issue 81 by abe...@gmail.com: how can xdocreport supply the
Chinese character.
http://code.google.com/p/xdocreport/issues/detail?id=81

It is possible to make font embedded by passing extra parameter to getFont
method
Now we use:
FontFactory.getFont( familyName, encoding, size, style, color );

but there is variant with embedded parameter:
FontFactory.getFont( familyName, encoding, embedded, size, style, color );

I think the bigger problem is how to search for a font
In example in an ODT document in style-text-properties we have:

style:font-name="Times New Roman" fo:font-size="12pt"
style:font-name-asian="Lucida Sans Unicode" style:font-size-asian="12pt"
style:language-asian="zxx" style:country-asian="none"
style:font-name-complex="Tahoma" style:font-size-complex="12pt"

so there is three font names. I don't know for now which to use and in what
circumstances. If I have ODT example and Chinese fonts I could do some
experiments.

Regards
Leszek


xdocr...@googlecode.com

unread,
Apr 3, 2012, 4:34:21 AM4/3/12
to xdocr...@googlegroups.com

Comment #5 on issue 81 by angelo.z...@gmail.com: how can xdocreport supply

Hi Leszek,

Many thanks for your answer. I will try to see how to docx works with
chinese characters and it's the same problem than ODT.

Guo could you attach to this issue please an ODT with Chinese characters.

Many thanks.

Regards Angelo


xdocr...@googlecode.com

unread,
Sep 28, 2012, 5:20:13 AM9/28/12
to xdocr...@googlegroups.com
Updates:
Owner: angelo.z...@gmail.com

Comment #6 on issue 81 by angelo.z...@gmail.com: how can xdocreport supply
A chinese people have blogged "How can XDocReport (to PDF) supply the
Chinese character ". See
http://acai-hsieh.blogspot.fr/2012/08/how-can-xdocreport-to-pdf-supply.html

It explains how to it has modified the docx converter to manage chine
character. here her code :

------------------------------------------------------------------------------------
// Get font
Font font =
XWPFFontRegistry.getRegistry().getFont( fontFamily,
options.getFontEncoding(), fontSize, fontStyle,
fontColor );

// 繁體中文
BaseFont bfChinese =
BaseFont.createFont("c:/Windows/Fonts/arialuni.ttf",
BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
Font fontChinese = new Font(bfChinese, font.getSize(),
font.getStyle(), font.getColor());
if (fontFamily != null)
fontChinese.setFamily(fontFamily);
font = fontChinese;
------------------------------------------------------------------------------------


It forces the font to Arial Uni. I don't understand how docx manage font.
It's my big problem. If anybody can explain me how docx manage font (how to
choose arial unicode when chinese character is used?) it should be very
cool to help me.

Many thank's

Regards Angelo

xdocr...@googlecode.com

unread,
Oct 5, 2012, 10:57:45 AM10/5/12
to xdocr...@googlegroups.com

Comment #7 on issue 81 by angelo.z...@gmail.com: how can xdocreport supply
I have added a new interface IFontProvider for ODT and DOCX PDF converter
that you can set it in the PdfOptions to manage as you wish the Font
creation. So with 1.0.0 you can do that:

-------------------------------------------------------------------------
PdfOptions options = PdfOptions.create();
options.fontProvider( new IFontProvider()
{

public Font getFont( String familyName, String encoding, float
size, int style, Color color )
{
try
{
BaseFont bfChinese =

BaseFont.createFont( "c:/Windows/Fonts/arialuni.ttf", BaseFont.IDENTITY_H,
BaseFont.EMBEDDED );
Font fontChinese = new Font( bfChinese, size, style,
color );
if ( familyName != null )
fontChinese.setFamily( familyName );
return fontChinese;
}
catch ( Exception e )
{
e.printStackTrace();
return null;
}
}
} );
PdfConverter.getInstance().convert( document, out, options );
-------------------------------------------------------------------------

It's not a clean solution but now I can convert the chinese character. It
shoul dbe cool if chinese people coul dexplain us how docx manage chinese
characters (I don't understand nothing?)

Regards Angelo

xdocr...@googlecode.com

unread,
Oct 9, 2012, 5:25:26 AM10/9/12
to xdocr...@googlegroups.com

xdocr...@googlecode.com

unread,
Oct 15, 2012, 1:42:29 AM10/15/12
to xdocr...@googlegroups.com

Comment #9 on issue 81 by chief...@gmail.com: how can xdocreport supply the
My notebook environment characters is big5,please find the test result at
the attachment.

a cai


Attachments:
surefire-reports.zip 5.6 KB
TestChineseCharacters.docx.pdf 149 KB

xdocr...@googlecode.com

unread,
Oct 15, 2012, 3:14:27 AM10/15/12
to xdocr...@googlegroups.com

Comment #10 on issue 81 by angelo.z...@gmail.com: how can xdocreport supply
Hi cai,

I'm sorry, but I don't understand your problem?

Could you explain me what is the problem.

Thank's

Regards Angelo

xdocr...@googlecode.com

unread,
Oct 15, 2012, 4:07:57 AM10/15/12
to xdocr...@googlegroups.com

Comment #11 on issue 81 by chief...@gmail.com: how can xdocreport supply
Hi Angelo,

Just provide test results in order to facilitate reference.
TestChineseCharacters.docx has two pages and TestChineseCharacters.docx.pdf
has five pages,TestChineseCharacters.docx.pdf of 2~4 pages are blank pages.

Thank's

a cai

xdocr...@googlecode.com

unread,
Oct 15, 2012, 4:50:13 AM10/15/12
to xdocr...@googlegroups.com

Comment #12 on issue 81 by angelo.z...@gmail.com: how can xdocreport supply
Hi cai,

I have noticed this problem, but it doesn't linked to the chinese
characters. I will study this problem.

Regards Angelo

xdocr...@googlecode.com

unread,
Oct 18, 2012, 10:37:38 AM10/18/12
to xdocr...@googlegroups.com

Comment #13 on issue 81 by angelo.z...@gmail.com: how can xdocreport supply
Problem is fixed. You can test it with our live demo
http://xdocreport-converter.opensagres.cloudbees.net/

There is just again a problem with first row of table which is start on the
first page although it should start of the second page.

Regards Angelo

xdocr...@googlecode.com

unread,
Jun 20, 2013, 9:23:49 PM6/20/13
to xdocr...@googlegroups.com

Comment #14 on issue 81 by chief...@gmail.com: how can xdocreport supply
Can reference "Test XDocReport v1.0.0".
http://acai-hsieh.blogspot.tw/2013/02/test-xdocreport-v100.html

--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

xdocr...@googlecode.com

unread,
Jun 21, 2013, 1:27:47 AM6/21/13
to xdocr...@googlegroups.com

Comment #15 on issue 81 by angelo.z...@gmail.com: how can xdocreport supply
Hi cai,

Many thank's for your article. For your information, Leszek and me are
improving (planned for 1.0.3) the pdf font in our converter and it should
fix problem whith chinese character (no need to force the use of a font
with "c:/Windows/Fonts/arialuni.ttf" (which works only with windows OS).

Regards Angelo

xdocr...@googlecode.com

unread,
Jun 21, 2013, 2:22:56 AM6/21/13
to xdocr...@googlegroups.com

Comment #16 on issue 81 by chief...@gmail.com: how can xdocreport supply
Thank's,I received.

xdocr...@googlecode.com

unread,
Aug 7, 2014, 5:00:09 PM8/7/14
to xdocr...@googlegroups.com
Updates:
Status: Done

Comment #17 on issue 81 by angelo.z...@gmail.com: how can xdocreport supply
(No comment was entered for this change.)
Reply all
Reply to author
Forward
0 new messages