I tried other encoding methods too (including BaseFont.IDENTITY_H)..But that
gives UnsupportedEncodingException:
Exception in thread "main" ExceptionConverter:
java.io.UnsupportedEncodingException: Identity-H
at java.lang.StringCoding.encode(StringCoding.java:269)
at java.lang.String.getBytes(String.java:946)
at com.lowagie.text.pdf.PdfEncodings.convertToBytes(Unknown Source)
at com.lowagie.text.pdf.Type1Font.<init>(Unknown Source)
at com.lowagie.text.pdf.BaseFont.createFont(Unknown Source)
at com.lowagie.text.pdf.BaseFont.createFont(Unknown Source)
at com.lowagie.text.pdf.BaseFont.createFont(Unknown Source)
at
com.compiere.itext.pdf.TestMultipleFonts.main(TestMultipleFonts.java:36)
Mark Storer-2 wrote:
>
> //BaseFont bf =
> BaseFont.createFont(BaseFont.TIMES_ROMAN,
> BaseFont.CP1257, BaseFont.EMBEDDED);
> //mapper = new
> AsianFontMapper(bf.getPostscriptFontName(),bf.getEncoding());
>
> Here's your trouble. You're using single byte encodings (Code Page 1257
> and whatever the defaultFontMapper uses) to encode characters that don't
> exist in one of the two encodings.
>
> Solution: Use BaseFont.IDENTITY_H instead. Encoding-Problems-B-Gone.
>
> --Mark Storer
> Sr Software Engineer
> Cardiff.com
>
> #include <disclaimer>
> typedef std::disclaimer<Cardiff> Discard;
>
>
> -----Original Message-----
> From: Saurabh Raval [mailto:[email protected]]
> Sent: Thursday, March 04, 2010 3:24 PM
> To: [email protected]
> Subject: [iText-questions] Problem printing accent, grave characters using
> graphics2D`
>
>
> I am having trouble creating PDF that contains characters: ė, ą. à, è, ì,
> ò,
> ù - À, È, Ì, Ò, ÙNormal font.
> If I use the DefaultFontMapper, the output contains: , , à, è, ì, ò, ù -
> À, È, Ì, Ò, ÙNormal font
> If I user the AsianFontMapper, the output contains:ė, ą. ,?,?,?,?..Normal
> font.
>
> I was not sure how to implement my own custom Font Mapper, so this email..
>
> My code is as follows:
>
> package itext.pdf;
>
> import java.awt.Graphics2D;
>
> import java.io.FileNotFoundException;
> import java.io.FileOutputStream;
> import java.io.IOException;
> import com.lowagie.text.Document;
> import com.lowagie.text.DocumentException;
> import com.lowagie.text.Rectangle;
> import com.lowagie.text.pdf.AsianFontMapper;
> import com.lowagie.text.pdf.BaseFont;
> import com.lowagie.text.pdf.DefaultFontMapper;
> import com.lowagie.text.pdf.PdfContentByte;
> import com.lowagie.text.pdf.PdfTemplate;
> import com.lowagie.text.pdf.PdfWriter;
>
> public class TestMultipleFonts {
>
> /**
> * @param args
> */
> public static void main(String[] args) {
>
> float w=500;
> float h=350;
> Rectangle pageSize = new Rectangle(w, h);
> Document doc = new Document(pageSize);
> try {
> FileOutputStream out = new
> FileOutputStream("/home/sraval/testPDF3.pdf");
> PdfWriter writer = PdfWriter.getInstance(doc, out);
> doc.open();
> PdfContentByte cb = writer.getDirectContent();
> PdfTemplate tp = cb.createTemplate(w, h);
> DefaultFontMapper mapper = new DefaultFontMapper();
> //BaseFont bf =
> BaseFont.createFont(BaseFont.TIMES_ROMAN,
> BaseFont.CP1257, BaseFont.EMBEDDED);
> //mapper = new
> AsianFontMapper(bf.getPostscriptFontName(),bf.getEncoding());
> Graphics2D g2D = tp.createGraphics(w, h, mapper);
>
> g2D.drawString("ė, ą. à, è, ì, ò, ù - À, È, Ì, Ò,
> ÙNormal font",10,10);
>
> g2D.dispose();
> cb.addTemplate(tp, 0, 0);
> doc.close();
> writer.close();
> out.close();
>
> } catch (FileNotFoundException e) {
> e.printStackTrace();
> } catch (DocumentException e) {
> e.printStackTrace();
> } catch (IOException e) {
> e.printStackTrace();
> }
> }
> }
>
> --
> View this message in context:
> http://old.nabble.com/Problem-printing-accent%2C-grave-characters-using-graphics2D%60-tp27788082p27788082.html
> Sent from the iText - General mailing list archive at Nabble.com.
>
>
> ------------------------------------------------------------------------------
> Download Intel® Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
> _______________________________________________
> iText-questions mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/itext-questions
>
> Buy the iText book: http://www.1t3xt.com/docs/book.php
> Check the site with examples before you ask questions:
> http://www.1t3xt.info/examples/
> You can also search the keywords list:
> http://1t3xt.info/tutorials/keywords/
>
> Internal Virus Database is out of date.
> Checked by AVG - www.avg.com
> Version: 9.0.730 / Virus Database: 271.1.1/2638 - Release Date: 01/21/10
> 23:34:00
> ------------------------------------------------------------------------------
> Download Intel® Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
> _______________________________________________
> iText-questions mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/itext-questions
>
> Buy the iText book: http://www.1t3xt.com/docs/book.php
> Check the site with examples before you ask questions:
> http://www.1t3xt.info/examples/
> You can also search the keywords list:
> http://1t3xt.info/tutorials/keywords/
>
--
View this message in context:
http://old.nabble.com/Problem-printing-accent%2C-grave-characters-using-graphics2D%60-tp27788082p27788489.html
Sent from the iText - General mailing list archive at Nabble.com.
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions:
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/