import java.lang.*;
import java.text.*;

import com.pdfjet.*;


/**
 *  Example_06.java
 *
 */
class Example_06 {

    public Example_06() throws Exception {
        PDF pdf = new PDF();

        pdf.setFontPath("c:/windows/fonts");
        Font f1 = new Font(pdf,
                "MyriadPro-Regular.otf", CodePage.CP1251, Embed.NO);
        Font f2 = new Font(pdf,
                "MyriadPro-Regular.otf", CodePage.CP1252, Embed.NO);
        Font f3 = new Font(pdf,
                "MinionPro-Regular.otf", CodePage.CP1253, Embed.NO);
        Font f4 = new Font(pdf, "ZapfDingbats");

        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.drawOn(page);
                buf = new StringBuilder();
            }
            buf.append((char) i);
        }

        pdf.wrap();
        pdf.save("Example_06.pdf");
    }


    public static void main(String[] args) {
        try {
            new Example_06();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}   // End of Example_06.java
