PDF jet

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


Example_05.pdf
using System;
using System.IO;

using PDFjet.NET;


/**
 *  Example_05.cs
 *
 */
public class Example_05 {

    public Example_05() {

        FileStream fos = new FileStream("Example_05.pdf", FileMode.Create);
        BufferedStream bos = new BufferedStream(fos);

        PDF pdf = new PDF(bos);

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

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

        TextLine text = new TextLine(f1);
        text.SetPosition(300.0f, 300.0f);
        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.0f, 50.0f);
        text.DrawOn(page);

        f1.SetKernPairs(true);
        text.SetPosition(70.0f, 70.0f);
        text.DrawOn(page);

        f1.SetKernPairs(false);
        text.SetPosition(70.0f, 90.0f);
        text.DrawOn(page);

        f1.SetSize(8.0f);
        text = new TextLine(f1, "-- font.SetKernPairs(false);");
        text.SetPosition(150.0f, 50.0f);
        text.DrawOn(page);
        text.SetPosition(150.0f, 90.0f);
        text.DrawOn(page);
        text = new TextLine(f1, "-- font.SetKernPairs(true);");
        text.SetPosition(150.0f, 70.0f);
        text.DrawOn(page);

        Point point = new Point(300.0f, 300.0f);
        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.0f);
        page.DrawEllipse(300.0f, 600.0f, 100.0f, 50.0f);

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

        pdf.Flush();
        bos.Close();
    }

    public static void Main(String[] args) {
        try {
            new Example_05();
        } catch (Exception e) {
            Console.WriteLine(e.StackTrace);
        }
    }

}   // End of Example_05.cs

© 2017 Innovatics Inc.