I am using Flying Saucer in a J2EE application. The server is configured to 
encode using UTF-8. I am required to keep this setting. I would like to know if 
there is a way to change the default character encoding from latin to UTF-8. It 
seem like there should be a method to set the encoding. 

I am aware of this instruction on 
https://xhtmlrenderer.dev.java.net/r7/users-guide-r7.html#configuration

import com.lowagie.text.pdf.BaseFont;

ITextRenderer renderer = new ITextRenderer();
FontResolver resolver = renderer.getFontResolver();
resolver.addFont (
"C:\\WINNT\\Fonts\\ARIALUNI.TTF",
BaseFont.IDENTITY_H,
BaseFont.NOT_EMBEDDED
);

This does not work for me, because i do not have ARIALUNI.TTF.

I did try using ARIAL.TTF, but that did not work. It give me the same error as 
if I did not use the FontResolver.

In other words
=================================================================
CodeSnippet1
=================================================================
String inputFile = "test.xhtml";
String url = new File(inputFile).toURI().toURL().toString();
String outputFile = "firstdoc.pdf";
OutputStream os = new FileOutputStream(outputFile);

ITextRenderer renderer = new ITextRenderer();
ITextFontResolver resolver = renderer.getFontResolver();
resolver.addFont ("C:\\WINDOWS\\Fonts\\ARIAL.TTF", BaseFont.IDENTITY_H, 
BaseFont.NOT_EMBEDDED);
renderer.setDocument(url);
renderer.layout();
renderer.createPDF(os);

os.close();

=================================================================

=================================================================
CodeSnippet2
=================================================================
String inputFile = "test.xhtml";
String url = new File(inputFile).toURI().toURL().toString();
String outputFile = "firstdoc.pdf";
OutputStream os = new FileOutputStream(outputFile);

ITextRenderer renderer = new ITextRenderer();
renderer.setDocument(url);
renderer.layout();
renderer.createPDF(os);

os.close();

=================================================================

CodeSnippet1 and CodeSnippet2 gives this exception.

org.xhtmlrenderer.util.XRRuntimeException: Can't load the XML resource (using 
TRaX transformer). java.io.IOException: Stream closed
at 
org.xhtmlrenderer.resource.XMLResource$XMLResourceBuilder.createXMLResource(XMLResource.java:191)
at org.xhtmlrenderer.resource.XMLResource.load(XMLResource.java:71)
at 
org.xhtmlrenderer.swing.NaiveUserAgent.getXMLResource(NaiveUserAgent.java:205)
at org.xhtmlrenderer.pdf.ITextRenderer.loadDocument(ITextRenderer.java:102)
at org.xhtmlrenderer.pdf.ITextRenderer.setDocument(ITextRenderer.java:106)

Again any help will be greatly appreciated.
[Message sent by forum member 'slink44' (slink44)]

http://forums.java.net/jive/thread.jspa?messageID=278969

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to