Hi all,
thank you for all your comments and help. I am still unable to get a
single character to come out in polish. I have, therefore, admitted
defeat and am going to ditch the old nasty code in favour of iText, a
free PDF generating library. It was so easy to get the characters to
display in the PDF using this:
package com.mydomain.pdf;
import java.io.FileOutputStream;
import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.Font;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.BaseFont;
import com.lowagie.text.pdf.PdfWriter;
import com.mydomain.sql.ConnectionFactory;
public class GenerateFulltextPDF {
public static void main(String[] args) {
String para = "";
try {
Connection con = ConnectionFactory.getConnection();
PreparedStatement stmt = con.prepareStatement("SELECT
wstf_fulltext FROM wstf WHERE wstf_wlng_id=2 LIMIT 1");
ResultSet res = stmt.executeQuery();
if (res.last()) {
para = res.getString(1);
}
} catch (SQLException e) {
e.printStackTrace();
}
Document document = new Document();
try {
PdfWriter writer = PdfWriter.getInstance(document, new
FileOutputStream("NewPage.pdf"));
BaseFont bf = BaseFont.createFont("Helvetica",
"iso-8859-2", true);
Font f = new Font(bf, 12);
document.open();
document.add(new Paragraph(para, f));
}
catch(DocumentException de) {
System.err.println(de.getMessage());
}
catch(IOException ioe) {
System.err.println(ioe.getMessage());
}
document.close();
}
}
and that's it! I've attached the PDF too.
I like the fact that FOP allows XSLT transformations into PDF, a very
powerful feature, but I can't do with it's pitiful unicode support.
Make it simple people! All we want to have to do is say: "this is
iso-8859-2, can you output the correct characters please" and for FOP
to say "no problem mate, if the font supports it"...
Alas, FOP is not for me at the moment. Perhaps when they sort the
unicode issues out it'll be worth coming back to. Good luck one and all
with your FOPing, I hope you manage where I have failed.
Paul.
Luis Ferro wrote:
On my "unicode" wars... i've found one site of huge value:
http://www.unicode.org/charts/charindex.html
This has ALL the unicode tables of ALL supported glyphs on ALL the standards
(specially important if you need just "that" glyph and you don't know it's
code).
I ended up consulting it regulary on my work.
Another page of some interest specially because of the use of Macs is:
http://www.alanwood.net/demos/charsetdiffs.html
Which can enlight why some characters appear and some don't.
Cheers,
LF
Paul Loy wrote:
Oh, forgot to mention that I'm on a mac.
Thanks for the suggestions so far!
Paul.
Kai Mütz wrote:
On windows systems you probably find Arial TTF files in windows fonts
directory ("C:\Windows\Fonts" on my machine). You can use the
TTFReader to create the metrics files as described at
http://xmlgraphics.apache.org/fop/trunk/fonts.html#truetype-metrics
-----Original Message-----
*From:*
[EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]*On
Behalf Of *Paul Loy
*Sent:* Monday, September 18, 2006 6:29 PM
*To:* [email protected]
*Subject:* Re: Unicode Fonts!!!!
yeah but that still doesn't give me the fonts I need. Where are
the unicode PS fonts that I can use?
Kai Mütz wrote:
Did you check: http://xmlgraphics.apache.org/fop/trunk/fonts.html?
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On
Behalf Of Paul Loy
Sent: Monday, September 18, 2006 5:35 PM
To: [email protected]
Subject: Re: Unicode Fonts!!!!
Do I have to translate all the foreign characters into a character
reference?
Paul Loy wrote:
Hi All,
I've inherited a poorly written system. Part of it uses FOP to
create
PDFs from an xslt. Now, we have international people on our site
which
is fine in HTML (xhtml1.1, utf-8) but when I try to use FOP I get
#
instead of any polish characters. I think this is due to the font
we
were using didn't have the unicode glyphs.
My question is, where are any unicode fonts for FOP. I just want
an
Arial or Helvetica type font, nothing fancy! Then, how do I use
this
font in my PDF? Here's a snippet of my xslt:
<xsl:template match="para">
<fo:block font-family="VAGRounded" font-weight="normal"
font-size="10pt" line-height="13pt" space-before.optimum="10pt"
space-after.optimum="10pt">
<xsl:apply-templates/>
</fo:block>
</xsl:template>
<xsl:template match="sup">
<fo:inline vertical-align="super"
font-size="8pt"><xsl:apply-templates/></fo:inline>
</xsl:template>
<xsl:template match="sub">
<fo:inline vertical-align="sub"
font-size="8pt"><xsl:apply-templates/></fo:inline>
</xsl:template>
<xsl:template match="i">
<fo:inline
font-style="italic"><xsl:apply-templates/></fo:inline>
</xsl:template>
<xsl:template match="i">
<fo:inline
text-decoration="underline"><xsl:apply-templates/></fo:inline>
</xsl:template>
<xsl:template match="pre">
<fo:block font-family="VAGRounded" font-weight="normal"
font-size="10pt" line-height="13pt" space-before.optimum="5pt"
space-after.optimum="5pt" white-space-collapse="false">
<xsl:apply-templates/>
</fo:block>
</xsl:template>
I've tried changing the VAGRounded bit to Arial, Helvetica, Times
New
Roman but I still don't get the characters to be in the final
PDF!!!
Thanks for any help,
Paul.
---------------------------------------------------------------------
To unsubscribe, e-mail:
[EMAIL PROTECTED]
For additional commands, e-mail:
[EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail:
[EMAIL PROTECTED]
For additional commands, e-mail:
[EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail:
[EMAIL PROTECTED]
This email has been scanned by Postini.
For more information please visit http://www.postini.com
This email has been scanned by Postini.
For more information please visit http://www.postini.com
|