Embedding Unicode Fonts - Please Note: Make sure that the font license allows embedding!
PDF pdf = new PDF();
pdf.setFontPath("fonts/Gentium102");
Font f1 = new Font(pdf, "GenR102.ttf", CodePage.UNICODE, Embed.YES);
// Please note:
// All font and image objects must be created before the first page.
Page page = new Page(pdf, Letter.PORTRAIT);
f1.setSize(18);
int x_pos = 200;
int y_pos = 20;
TextLine text = new TextLine(f1);
|
|
text.setPosition(x_pos, y_pos);
StringBuilder buf = new StringBuilder();
for (int i = 0x20; i < 0x7F; i++) {
if (i % 16 == 0) {
text.setText(buf.toString());
text.setPosition(x_pos, y_pos += 24);
text.drawOn(page);
buf = new StringBuilder();
}
buf.append((char) i);
}
|
|
y_pos += 24;
buf = new StringBuilder();
for (int i = 0x390; i < 0x3EF; i++) {
if (i % 16 == 0) {
text.setText(buf.toString());
text.setPosition(x_pos, y_pos += 24);
text.drawOn(page);
buf = new StringBuilder();
}
buf.append((char) i);
}
|
|
y_pos += 24;
buf = new StringBuilder();
for (int i = 0x400; i < 0x46F; i++) {
if (i % 16 == 0) {
text.setText(buf.toString());
text.setPosition(x_pos, y_pos += 24);
text.drawOn(page);
buf = new StringBuilder();
}
buf.append((char) i);
}
|
|
pdf.wrap();
pdf.save("Example_07.pdf");
|
|
| Example_07.java | Example_07.pdf |
© 2007 Innovatics Inc.



