XSLT transformation to PDF, Chinese characters lost

2004-09-23 Thread Mike J Boyersmith

Problem: generated PDF file
shows '#' characters instead of Chinese characters. 

So I dug around on the faqs and
archives and didn't see a specific example that shows how to accomplish
what
I'm trying to do heres
the problem, I have a xslt file which gets loaded and transformed via java
code. 

The transformation does the following:

1) Creates a .fo file
2) Calls an XSLT extension to generate
the PDF file, using the .fo file it just produced

In detail here what I do.

Java code executes Transformation-
transformation creates .fo file--transformation then grabs file and
passes it to a XSLT extension which produces the pdf file. 


The XSLT extension java code looks
like

public static void createPDF (String
foFileName, String pdfFileName) {

.. do setup work

// Create a new FOP driver
object
Driver driver = new Driver();

   
// Setup FOP with a logger
Logger logger = new ConsoleLogger(ConsoleLogger.LEVEL_INFO);
driver.setLogger(logger);
MessageHandler.setScreenLogger(logger);

// Setup FOP to render PDF
   
driver.setRenderer (Driver.RENDER_PDF);

   
// Create an output stream
for the pdf file and tell FOP about it
out = new java.io.FileOutputStream
(pdfFile);
driver.setOutputStream (out);

// Create an input stream
for the fo file and tell FOP about it
in = new java.io.FileInputStream
(foFile); driver.setInputSource (new InputSource (in));

// Generate the output
driver.run();

the xslt for the extension looks
like

xsl:value-of select=java:com.xxx.core.internal.XSLT.XSLTExtension.createPDF($foFullPathName,
$reportFullPathName)/


This all works great BUT!! The
problem is that on Chinese if I have text that has Chinese characters they
are replaced with # characters, and I can figure no way around this.

So. Digging around I see that I need
to embed fonts, but...

How do I do this programmatically?
How do I do this so it works on Windows
and Linux?



Re: XSLT transformation to PDF, Chinese characters lost

2004-09-23 Thread Mike J Boyersmith


On 23.09.2004 20:24:22 Mike J Boyersmith wrote:
 Problem: generated PDF file shows '#' characters instead
of Chinese 
 characters. 

As you probably found out yourself, this here applies:
http://xml.apache.org/fop/faq.html#pdf-characters

yup saw that, I found the FOP examples to... but not
One of them shows how to do a
end to end walk through of dealing with language/i18n
type issues :(. That would be a 
great addition to the examples collection. 

snip/
 This all works great BUT!! The problem is that on Chinese
if I have 
 text that has Chinese characters they are replaced with '#' characters,

 and I can figure no way around this.
 
 So. Digging around I see that I need to embed fonts, but
 How do I do this programmatically?

Create the font metrics XML for your TrueType fonts as described
here:
http://xml.apache.org/fop/fonts.html

Then use the userconfig.xml as described here:
http://xml.apache.org/fop/embedding.html#config-external

It's probably best to try on the command-line first and then port
the
whole thing into Java 

How do I do this so it works on Windows and
Linux?

Don't worry about that. It works the same way on both platforms.
That's
because FOP uses its own font subsystem for PDF and PS output.

Would be nice if I could just specify font-family,
and it would all work, but
guess I'm dreaming. will try walking through the problem
from the command line as you suggested.

Thanks for the quick reply :D