PDF jet

Using Point object to draw circles. Changing text direction and kerning


Example_05.pdf
import java.io.*;

import com.pdfjet.*;


/**
 *  Example_05.java
 *
 */
public class Example_05 {

    public Example_05() throws Exception {

        FileOutputStream fos = new FileOutputStream("Example_05.pdf");

        PDF pdf = new PDF(fos);

        Font f1 = new Font(pdf, CoreFont.HELVETICA_BOLD);

        Page page = new Page(pdf, Letter.PORTRAIT);

        TextLine text = new TextLine(f1);
        text.setPosition(300.0, 300.0);
        for (int i = 0; i < 360; i += 15) {
            text.setTextDirection(i);
            text.setUnderline(true);
            // text.setStrikeLine(true);
            text.setText("             Hello, World -- " + i + " degrees.");
            text.drawOn(page);
        }

        text = new TextLine(f1, "WAVE AWAY");
        text.setPosition(70.0, 50.0);
        text.drawOn(page);

        f1.setKernPairs(true);
        text = new TextLine(f1, "WAVE AWAY");
        text.setPosition(70.0, 70.0);
        text.drawOn(page);

        f1.setKernPairs(false);
        text = new TextLine(f1, "WAVE AWAY");
        text.setPosition(70.0, 90.0);
        text.drawOn(page);

        f1.setSize(8);
        text = new TextLine(f1, "-- font.setKernPairs(false);");
        text.setPosition(150.0, 50.0);
        text.drawOn(page);
        text.setPosition(150.0, 90.0);
        text.drawOn(page);
        text = new TextLine(f1, "-- font.setKernPairs(true);");
        text.setPosition(150.0, 70.0);
        text.drawOn(page);

        Point point = new Point(300.0, 300.0);
        point.setShape(Point.CIRCLE);
        point.setFillShape(true);
        point.setColor(Color.blue);
        point.setRadius(37.0f);
        point.drawOn(page);
        point.setRadius(25.0f);
        point.setColor(Color.white);
        point.drawOn(page);

        page.setPenWidth(1.0);
        page.drawEllipse(300.0f, 600.0f, 100.0f, 50.0f);

        f1.setSize(14.0);        
        String unicode =
                "\u20AC\u0020\u201A\u0192\u201E\u2026\u2020\u2021\u02C6\u2030\u0160";
        text = new TextLine(f1, unicode);
        text.setPosition(100.0, 700.0);
        text.drawOn(page);

        pdf.flush();
        fos.close();
    }

    public static void main(String[] args) {
        try {
            new Example_05();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}   // End of Example_05.java

© 2017 Innovatics Inc.