import java.io.*;
import com.pdfjet.*;
/**
* Example_06.java
*/
class Example_06 {
public Example_06() throws Exception {
PDF pdf = new PDF(new FileOutputStream("Example_06.pdf"));
BufferedInputStream bis1 = new BufferedInputStream(
getClass().getResourceAsStream(
"fonts/DroidFonts/DroidSerif-Regular.otf"));
Font f1 = new Font(pdf, bis1, CodePage.CP1251, Embed.YES);
BufferedInputStream bis2 = new BufferedInputStream(
getClass().getResourceAsStream(
"fonts/DroidFonts/DroidSerif-Regular.otf"));
Font f2 = new Font(pdf, bis2, CodePage.CP1252, Embed.YES);
BufferedInputStream bis3 = new BufferedInputStream(
getClass().getResourceAsStream(
"fonts/DroidFonts/DroidSerif-Regular.otf"));
Font f3 = new Font(pdf, bis3, CodePage.CP1253, Embed.YES);
Font f4 = new Font(pdf, CoreFont.ZAPF_DINGBATS);
Page page = new Page(pdf, Letter.PORTRAIT);
int x_pos = 50;
int y_pos = 0;
f1.setSize(20);
f2.setSize(20);
f3.setSize(20);
f4.setSize(18);
TextLine text = new TextLine(f1);
text.setPosition(x_pos, y_pos);
StringBuilder buf = new StringBuilder();
for (int i = 32; i <= 256; i++) {
if (i % 32 == 0) {
text.setText(buf.toString());
text.setPosition(x_pos, y_pos += 24);
text.drawOn(page);
buf = new StringBuilder();
}
buf.append((char) i);
}
text.setFont(f2);
buf = new StringBuilder();
for (int i = 32; i <= 256; i++) {
if (i % 32 == 0) {
text.setText(buf.toString());
text.setPosition(x_pos, y_pos += 24);
text.drawOn(page);
buf = new StringBuilder();
}
buf.append((char) i);
}
text.setFont(f3);
buf = new StringBuilder();
for (int i = 32; i <= 256; i++) {
if (i == 210 || i == 242) {
// Character 210 is not mapped in the 1253 code page
// Character 242 - "SIGMA FINAL" is not available in this font
continue;
}
if (i % 32 == 0) {
text.setText(buf.toString());
text.setPosition(x_pos, y_pos += 24);
text.drawOn(page);
buf = new StringBuilder();
}
buf.append((char) i);
}
text.setFont(f4);
buf = new StringBuilder();
for (int i = 32; i <= 256; i++) {
if (i % 32 == 0) {
text.setText(buf.toString());
text.setPosition(x_pos, y_pos += 22);
text.setUnderline( true );
text.drawOn(page);
buf = new StringBuilder();
}
buf.append((char) i);
}
pdf.complete();
}
public static void main(String[] args) throws Exception {
new Example_06();
}
} // End of Example_06.java
© 2023 Innovatics Inc.