using System;
using System.Text;
using System.IO;
using PDFjet.NET;
/**
* Example_06.cs
*
*/
class Example_06 {
public Example_06() {
FileStream fos = new FileStream("Example_06.pdf", FileMode.Create);
BufferedStream bos = new BufferedStream(fos);
PDF pdf = new PDF(bos);
// Before you enable this flag please read PDFJET.ZLIB.TXT
// in the "optional" directory.
// pdf.setCompressor(Compressor.ORIGINAL_ZLIB);
FileStream fis1 = new FileStream(
"fonts/DroidFonts/DroidSerif-Regular.otf", FileMode.Open);
Font f1 = new Font(pdf, fis1, CodePage.CP1251, Embed.YES);
FileStream fis2 = new FileStream(
"fonts/DroidFonts/DroidSerif-Regular.otf", FileMode.Open);
Font f2 = new Font(pdf, fis2, CodePage.CP1252, Embed.YES);
FileStream fis3 = new FileStream(
"fonts/DroidFonts/DroidSerif-Regular.otf", FileMode.Open);
Font f3 = new Font(pdf, fis3, 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) {
// Char 210 is not mapped in the 1253 code page
// Char 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.Flush();
bos.Close();
}
public static void Main(String[] args) {
try {
new Example_06();
} catch (Exception e) {
Console.WriteLine(e.StackTrace);
}
}
} // End of Example_06.cs
© 2011 Innovatics Inc.
