コード例 #1
0
    public Example_02()
    {
        PDF pdf = new PDF(new BufferedStream(
                              new FileStream("Example_02.pdf", FileMode.Create)));

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

        Box flag = new Box(85.0f, 85.0f, 64.0f, 32.0f);

        PDFjet.NET.Path path = new PDFjet.NET.Path();
        path.Add(new Point(13.0f, 0.0f));
        path.Add(new Point(15.5f, 4.5f));

        path.Add(new Point(18.0f, 3.5f));
        path.Add(new Point(15.5f, 13.5f, Point.CONTROL_POINT));
        path.Add(new Point(15.5f, 13.5f, Point.CONTROL_POINT));
        path.Add(new Point(20.5f, 7.5f));

        path.Add(new Point(21.0f, 9.5f));
        path.Add(new Point(25.0f, 9.0f));
        path.Add(new Point(24.0f, 13.0f));
        path.Add(new Point(25.5f, 14.0f));
        path.Add(new Point(19.0f, 19.0f));
        path.Add(new Point(20.0f, 21.5f));
        path.Add(new Point(13.5f, 20.5f));
        path.Add(new Point(13.5f, 27.0f));
        path.Add(new Point(12.5f, 27.0f));
        path.Add(new Point(12.5f, 20.5f));
        path.Add(new Point(6.0f, 21.5f));
        path.Add(new Point(7.0f, 19.0f));
        path.Add(new Point(0.5f, 14.0f));
        path.Add(new Point(2.0f, 13.0f));
        path.Add(new Point(1.0f, 9.0f));
        path.Add(new Point(5.0f, 9.5f));

        path.Add(new Point(5.5f, 7.5f));
        path.Add(new Point(10.5f, 13.5f, Point.CONTROL_POINT));
        path.Add(new Point(10.5f, 13.5f, Point.CONTROL_POINT));
        path.Add(new Point(8.0f, 3.5f));

        path.Add(new Point(10.5f, 4.5f));
        path.SetClosePath(true);
        path.SetColor(Color.red);
        path.SetFillShape(true);
        path.PlaceIn(flag, 19.0f, 3.0f);
        path.DrawOn(page);

        Box box = new Box();

        box.SetSize(16, 32);
        box.SetColor(Color.red);
        box.SetFillShape(true);
        box.PlaceIn(flag, 0.0, 0.0);
        box.DrawOn(page);
        box.PlaceIn(flag, 48.0, 0.0);
        box.DrawOn(page);

        path.ScaleBy(15.0);
        path.SetFillShape(false);
        float[] xy = path.DrawOn(page);

        box = new Box();
        box.SetLocation(xy[0], xy[1]);
        box.SetSize(20f, 20f);
        box.DrawOn(page);

        pdf.Complete();
    }
コード例 #2
0
    public Example_20()
    {
        PDF pdf = new PDF(new BufferedStream(
                              new FileStream("Example_20.pdf", FileMode.Create)));

        BufferedStream bis = new BufferedStream(
            new FileStream("data/testPDFs/PDFjetLogo.pdf", FileMode.Open));
        SortedDictionary <Int32, PDFobj> objects = pdf.Read(bis);

        bis.Close();

        pdf.AddResourceObjects(objects);

        Font f1 = new Font(pdf, new FileStream(
                               "fonts/OpenSans/OpenSans-Regular.ttf.stream",
                               FileMode.Open,
                               FileAccess.Read), Font.STREAM);

        f1.SetSize(18f);

        List <PDFobj> pages    = pdf.GetPageObjects(objects);
        PDFobj        contents = pages[0].GetContentsObject(objects);

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

        float height = 105f;    // The logo height in points.
        float x      = 50f;
        float y      = 50f;
        float xScale = 0.5f;
        float yScale = 0.5f;

        page.DrawContents(
            contents.GetData(),
            height,
            x,
            y,
            xScale,
            yScale);

        page.SetPenColor(Color.darkblue);
        page.SetPenWidth(0f);
        page.DrawRect(0f, 0f, 50f, 50f);

        PDFjet.NET.Path path = new PDFjet.NET.Path();

        path.Add(new Point(13.0f, 0.0f));
        path.Add(new Point(15.5f, 4.5f));

        path.Add(new Point(18.0f, 3.5f));
        path.Add(new Point(15.5f, 13.5f, Point.CONTROL_POINT));
        path.Add(new Point(15.5f, 13.5f, Point.CONTROL_POINT));
        path.Add(new Point(20.5f, 7.5f));

        path.Add(new Point(21.0f, 9.5f));
        path.Add(new Point(25.0f, 9.0f));
        path.Add(new Point(24.0f, 13.0f));
        path.Add(new Point(25.5f, 14.0f));
        path.Add(new Point(19.0f, 19.0f));
        path.Add(new Point(20.0f, 21.5f));
        path.Add(new Point(13.5f, 20.5f));
        path.Add(new Point(13.5f, 27.0f));
        path.Add(new Point(12.5f, 27.0f));
        path.Add(new Point(12.5f, 20.5f));
        path.Add(new Point(6.0f, 21.5f));
        path.Add(new Point(7.0f, 19.0f));
        path.Add(new Point(0.5f, 14.0f));
        path.Add(new Point(2.0f, 13.0f));
        path.Add(new Point(1.0f, 9.0f));
        path.Add(new Point(5.0f, 9.5f));

        path.Add(new Point(5.5f, 7.5f));
        path.Add(new Point(10.5f, 13.5f, Point.CONTROL_POINT));
        path.Add(new Point(10.5f, 13.5f, Point.CONTROL_POINT));
        path.Add(new Point(8.0f, 3.5f));

        path.Add(new Point(10.5f, 4.5f));
        path.SetClosePath(true);
        path.SetColor(Color.red);
        // path.SetFillShape(true);
        path.SetLocation(100f, 100f);
        path.ScaleBy(10f);

        path.DrawOn(page);

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

        TextLine line = new TextLine(f1, "Hello, World!");

        line.SetLocation(50f, 50f);
        line.DrawOn(page);

        QRCode qr = new QRCode(
            "http://d-project.googlecode.com/svn/trunk/misc/qrcode/as3/src/sample",
            ErrorCorrectLevel.L);       // Low

        qr.SetModuleLength(3f);
        qr.SetLocation(50f, 200f);
        qr.DrawOn(page);

        pdf.Close();
    }
コード例 #3
0
    public Example_02()
    {
        FileStream     fos = new FileStream("Example_02.pdf", FileMode.Create);
        BufferedStream bos = new BufferedStream(fos);

        PDF pdf = new PDF(bos);

        pdf.setCompressor(Compressor.ORIGINAL_ZLIB);

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

        Box flag = new Box(85, 85, 64, 32);

        PDFjet.NET.Path path = new PDFjet.NET.Path();
        path.Add(new Point(13.0, 0.0));
        path.Add(new Point(15.5, 4.5));
        path.Add(new Point(18.0, 3.5));

        path.Add(new Point(15.5, 13.5, Point.IS_CURVE_POINT));
        path.Add(new Point(15.5, 13.5, Point.IS_CURVE_POINT));
        path.Add(new Point(20.5, 7.5, Point.IS_CURVE_POINT));

        path.Add(new Point(21.0, 9.5));
        path.Add(new Point(25.0, 9.0));
        path.Add(new Point(24.0, 13.0));
        path.Add(new Point(25.5, 14.0));
        path.Add(new Point(19.0, 19.0));
        path.Add(new Point(20.0, 21.5));
        path.Add(new Point(13.5, 20.5));
        path.Add(new Point(13.5, 27.0));
        path.Add(new Point(12.5, 27.0));
        path.Add(new Point(12.5, 20.5));
        path.Add(new Point(6.0, 21.5));
        path.Add(new Point(7.0, 19.0));
        path.Add(new Point(0.5, 14.0));
        path.Add(new Point(2.0, 13.0));
        path.Add(new Point(1.0, 9.0));
        path.Add(new Point(5.0, 9.5));
        path.Add(new Point(5.5, 7.5));

        path.Add(new Point(10.5, 13.5, Point.IS_CURVE_POINT));
        path.Add(new Point(10.5, 13.5, Point.IS_CURVE_POINT));
        path.Add(new Point(8.0, 3.5, Point.IS_CURVE_POINT));

        path.Add(new Point(10.5, 4.5));
        path.setClosePath(true);
        path.SetColor(RGB.RED);
        path.SetFillShape(true);
        path.PlaceIn(flag, 19.0, 3.0);
        path.DrawOn(page);

        Box box = new Box();

        box.SetSize(16, 32);
        box.SetColor(RGB.RED);
        box.SetFillShape(true);
        box.PlaceIn(flag, 0.0, 0.0);
        box.DrawOn(page);
        box.PlaceIn(flag, 48.0, 0.0);
        box.DrawOn(page);

        path.ScaleBy(15.0);
        path.SetFillShape(false);
        path.DrawOn(page);

        pdf.Flush();
        bos.Close();
    }
コード例 #4
0
    public Example_02()
    {
        FileStream fos = new FileStream("Example_02.pdf", FileMode.Create);
        BufferedStream bos = new BufferedStream(fos);

        PDF pdf = new PDF(bos);
        pdf.setCompressor(Compressor.ORIGINAL_ZLIB);

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

        Box flag = new Box(85, 85, 64, 32);

        PDFjet.NET.Path path = new PDFjet.NET.Path();
        path.Add(new Point(13.0,  0.0));
        path.Add(new Point(15.5,  4.5));
        path.Add(new Point(18.0,  3.5));

        path.Add(new Point(15.5, 13.5, Point.IS_CURVE_POINT));
        path.Add(new Point(15.5, 13.5, Point.IS_CURVE_POINT));
        path.Add(new Point(20.5,  7.5, Point.IS_CURVE_POINT));

        path.Add(new Point(21.0,  9.5));
        path.Add(new Point(25.0,  9.0));
        path.Add(new Point(24.0, 13.0));
        path.Add(new Point(25.5, 14.0));
        path.Add(new Point(19.0, 19.0));
        path.Add(new Point(20.0, 21.5));
        path.Add(new Point(13.5, 20.5));
        path.Add(new Point(13.5, 27.0));
        path.Add(new Point(12.5, 27.0));
        path.Add(new Point(12.5, 20.5));
        path.Add(new Point( 6.0, 21.5));
        path.Add(new Point( 7.0, 19.0));
        path.Add(new Point( 0.5, 14.0));
        path.Add(new Point( 2.0, 13.0));
        path.Add(new Point( 1.0,  9.0));
        path.Add(new Point( 5.0,  9.5));
        path.Add(new Point( 5.5,  7.5));

        path.Add(new Point(10.5, 13.5, Point.IS_CURVE_POINT));
        path.Add(new Point(10.5, 13.5, Point.IS_CURVE_POINT));
        path.Add(new Point( 8.0,  3.5, Point.IS_CURVE_POINT));

        path.Add(new Point(10.5,  4.5));
        path.setClosePath(true);
        path.SetColor(RGB.RED);
        path.SetFillShape(true);
        path.PlaceIn(flag, 19.0, 3.0);
        path.DrawOn(page);

        Box box = new Box();
        box.SetSize(16, 32);
        box.SetColor(RGB.RED);
        box.SetFillShape(true);
        box.PlaceIn(flag, 0.0, 0.0);
        box.DrawOn(page);
        box.PlaceIn(flag, 48.0, 0.0);
        box.DrawOn(page);

        path.ScaleBy(15.0);
        path.SetFillShape(false);
        path.DrawOn(page);

        pdf.Flush();
        bos.Close();
    }
コード例 #5
0
    public Example_22()
    {
        PDF pdf = new PDF(new BufferedStream(
                              new FileStream("Example_22.pdf", FileMode.Create)),
                          Compliance.PDF_UA);

        Font f1 = new Font(pdf, new FileStream(
                               "fonts/OpenSans/OpenSans-Regular.ttf.stream",
                               FileMode.Open,
                               FileAccess.Read), Font.STREAM);

/*
 *      PDF pdf = new PDF(new FileStream("Example_22.pdf", FileMode.Create));
 *
 *      Font f1 = new Font(pdf, CoreFont.HELVETICA);
 */
        Page     page = new Page(pdf, Letter.PORTRAIT);
        TextLine text = new TextLine(f1, "Page #1 -> Go to Destination #3.");

        text.SetGoToAction("dest#3");
        text.SetLocation(90f, 50f);
        page.AddDestination("dest#0", 0f);
        page.AddDestination("dest#1", text.GetDestinationY());
        text.DrawOn(page);

        page = new Page(pdf, Letter.PORTRAIT);
        text = new TextLine(f1, "Page #2 -> Go to Destination #3.");
        text.SetGoToAction("dest#3");
        text.SetLocation(90f, 550f);
        page.AddDestination("dest#2", text.GetDestinationY());
        text.DrawOn(page);

        page = new Page(pdf, Letter.PORTRAIT);
        text = new TextLine(f1, "Page #3 -> Go to Destination #4.");
        text.SetGoToAction("dest#4");
        text.SetLocation(90f, 700f);
        page.AddDestination("dest#3", text.GetDestinationY());
        text.DrawOn(page);

        page = new Page(pdf, Letter.PORTRAIT);
        text = new TextLine(f1, "Page #4 -> Go to Destination #0.");
        text.SetGoToAction("dest#0");
        text.SetLocation(90f, 100f);
        page.AddDestination("dest#4", text.GetDestinationY());
        text.DrawOn(page);

        text = new TextLine(f1, "Page #4 -> Go to Destination #2.");
        text.SetGoToAction("dest#2");
        text.SetLocation(90f, 200f);
        text.DrawOn(page);

        // Create a box with invisible borders
        Box box = new Box(20f, 20f, 20f, 20f);

        box.SetColor(Color.white);
        box.SetGoToAction("dest#0");
        box.DrawOn(page);

        // Create an up arrow and place it in the box
        PDFjet.NET.Path path = new PDFjet.NET.Path();
        path.Add(new Point(10f, 1f));
        path.Add(new Point(17f, 9f));
        path.Add(new Point(13f, 9f));
        path.Add(new Point(13f, 19f));
        path.Add(new Point(7f, 19f));
        path.Add(new Point(7f, 9f));
        path.Add(new Point(3f, 9f));
        path.SetClosePath(true);
        path.SetColor(Color.oldgloryblue);
        path.SetColor(Color.deepskyblue);
        path.SetFillShape(true);
        path.PlaceIn(box);
        path.DrawOn(page);

        FileStream fis = new FileStream(
            "images/up-arrow.png", FileMode.Open, FileAccess.Read);
        Image image = new Image(pdf, fis, ImageType.PNG);

        image.SetLocation(40f, 40f);
        image.SetGoToAction("dest#0");
        image.DrawOn(page);

        pdf.Complete();
    }