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/