sonnv56 / xdocreport

Automatically exported from code.google.com/p/xdocreport
0 stars 0 forks source link

Problem with Language in Google App Engine #230

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
My Project. I have wrote the project on my localhost and run is ok.
When I deploy in Google App Engine and try it with english language is no 
problem also.
Then I change the parameter to Thai language the output is disappear.

Try with this link below.
English Language
http://iesstoragedemo.appspot.com/gstorage/reportDispatcher?reportId=DocxProject
WithVelocity.docx&name=XDocReport&converter=PDF_XWPF&dispatch=view
Thai Language
http://iesstoragedemo.appspot.com/gstorage/reportDispatcher?reportId=DocxProject
WithVelocity.docx&name=ทดสอบ&converter=PDF_XWPF&dispatch=view

Note: On Local host everything is ok.
Note2: Font I used with Calibri.

What should i do.

Original issue reported on code.google.com by administ...@iessystem.com on 28 Feb 2013 at 1:14

Attachments:

GoogleCodeExporter commented 9 years ago
I forgot something to tell.
When I don't convert to pdf and download via docx the language is no problem 
also.

http://iesstoragedemo.appspot.com/gstorage/reportDispatcher?reportId=DocxProject
WithVelocity.docx&name=ทดสอบ

Original comment by administ...@iessystem.com on 28 Feb 2013 at 1:21

GoogleCodeExporter commented 9 years ago
Hi,

I seems that your problem is with iText (PDF converter). If it works on 
localhost and not on the Google App Engine, I suppose that it miss in this 
server the font. I'm not expert with that.

Regards Angelo

Regards Angelo

Original comment by angelo.z...@gmail.com on 28 Feb 2013 at 1:42

GoogleCodeExporter commented 9 years ago
Second Test for various font.

When I used for each font with English Language is passed.
Then I used that font as the same and type in THAI language , the content is 
disappear.

Link to test.
http://iesstoragedemo.appspot.com/gstorage/reportDispatcher?reportId=xxx.docx&na
me=XDocReport&converter=PDF_XWPF&dispatch=view

Original comment by administ...@iessystem.com on 28 Feb 2013 at 3:51

Attachments:

GoogleCodeExporter commented 9 years ago
As I said you, I think your Google App Engine doesn't provide the well font. I 
think your problem comes from with config of your server if it works on your 
local server.

Original comment by angelo.z...@gmail.com on 28 Feb 2013 at 4:01

GoogleCodeExporter commented 9 years ago
Thank you very much.
As you said . gae probably not support with Thai Language Font.

I have to download to docx format only to get well about output. 

Original comment by administ...@iessystem.com on 28 Feb 2013 at 4:22

GoogleCodeExporter commented 9 years ago
I has similar problem. I can suppose that you development environment is On 
Windows, and you server is a kind of unix system. So, in window you have all 
fonts, and on linux ofcorse MS fonts are not present.

If you server is on linux, next what will be very informative for You, is to 
prepare some unit tests, and run them on you *nix environment and on windows 
environment. If on Win all will be OK, and on *nix wrong, you have to think 
about installing MS fonts on *nix, or whatever, the fix of fonts problem on 
linux you can find using google.

P.S.
My comment is just a direction of the solving you problem, as I said upper.. I 
suppose

Original comment by ruslancu...@gmail.com on 1 Mar 2013 at 2:11

GoogleCodeExporter commented 9 years ago
We have the same problem with our XDocReport live demo. With my local computer 
(Windows), my fonts works and with our XDocReport live demo (cloudbee which is 
based on Linux server) there are problems with some characters (like chinese).

I don't know how we could fix that.

Original comment by angelo.z...@gmail.com on 1 Mar 2013 at 2:20

GoogleCodeExporter commented 9 years ago
It is matter of font's and may be app server encoding.

I has problem with sme spanish char's. I fix this problems as:
1. force whole project to use UTF-8 encoding
2. set java default encoding: -Dfile.encoding=whatever(in my case UTF-8)

Next problem which I can see here, is that doc template is edited on Windows, 
on which default encoding can be whatever but not UTF-8(it is a mess how 
windows treat encodings).

So, I think that it is a matter of some improvement in XDoc related to 
encodings(to be more specific is to detect't template encoding and force 
template engine to generate text in document template encoding).

next problem here can be font's when generating iText. The thing (what I 
understood by brief reding of the itext overview) is that iText manage fonts 
inside, and do some font transformations, so if document encoding is one, JVM 
work's with another encoding, while iText try to manage himself encodings and 
font's, it is clear that this will generate problems.

So, in the time when we can't manage iText encodings/fonts managing, I think 
that we should try to fix this inside of XDocReport. The only solution for 
iText is to install missing fonts on linux machine(thx to penguins we can 
install there ms fonts).

P.S.
Once again. I didn't test this, I just made conclusion by breafly reading 
documentation, but in any way, hope my comment will be helpeful for someone

Original comment by ruslancu...@gmail.com on 1 Mar 2013 at 2:30

GoogleCodeExporter commented 9 years ago
Many thank's for this information.

Don't hesitate to provide some patches if you resolve your problem.

Many thank's

Regards Angelo

Original comment by angelo.z...@gmail.com on 1 Mar 2013 at 2:33

GoogleCodeExporter commented 9 years ago
Many thank's for this information.

Don't hesitate to provide some patches if you resolve your problem.

Many thank's

Regards Angelo

Original comment by angelo.z...@gmail.com on 1 Mar 2013 at 2:33

GoogleCodeExporter commented 9 years ago
Angelo...
In my opinion there is not necessary to add support for encodings.
UTF-8 is kind of encoding which should permit display/print all(or most) 
characters from all(or most) laguages(fonts). So, In my opinion is better to 
fix you problem on linux server, by installing font's for itext, and a write a 
wiki page with XDOc limitation related to encodings(that is limited to using 
only UTF-8 encoding).

P.S.
By the way, can you please prepare some unit test and send to me to simulate 
you error with chineese chars. My development machine is drived by linux, so I 
can investigate how to fix you problem.

Have a nice day.

Original comment by ruslancu...@gmail.com on 1 Mar 2013 at 2:38

GoogleCodeExporter commented 9 years ago
>  is better to fix you problem on linux server, by installing font's for itext
I agree with you.

> write a wiki page with XDOc limitation related to encodings
If you can write something about this topic, I will be happy to add it to the 
wiki. Thank's!

> can you please prepare some unit test and send to me to simulate you error 
with chineese chars.

I'm not an expert with chineese chars. At first I don't understand how docx 
manages chars font. The only mean that I have found to manage chinese is to 
force the font to "arialuni.ttf" (not very clean solution adn it works only 
with windows).

See 
https://code.google.com/p/xdocreport/source/browse/thirdparties-extension/org.od
ftoolkit.odfdom.converter.pdf/src/test/java/org/odftoolkit/odfdom/converter/pdf/
PdfConvertChineseTestCase.java 

Regards Angelo

Original comment by angelo.z...@gmail.com on 4 Mar 2013 at 8:24

GoogleCodeExporter commented 9 years ago
//
    // read template
    //
    File docxFile = new File(System.getProperty("user.dir") + "/" + "Test.docx");
    InputStream in = new FileInputStream(docxFile);

    // 
    // prepare document context
    //
    IXDocReport report = XDocReportRegistry.getRegistry().loadReport(in, TemplateEngineKind.Velocity);
    IContext context = report.createContext();
    context.put("name", "Michael Küfner");

    // 
    // generate PDF output
    //
    Options options = Options.getTo(ConverterTypeTo.PDF).via(ConverterTypeVia.XWPF);
    PdfOptions pdfOptions = PdfOptions.create();
    pdfOptions.fontEncoding("iso-8859-15");
    options.subOptions(pdfOptions);     

    OutputStream out = new FileOutputStream(new File(docxFile.getPath() + ".pdf"));
    report.convert(context, options, out);

Original comment by ricsim...@gmail.com on 2 Apr 2014 at 6:42