示例#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();
    }
    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();
    }
示例#3
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();
    }
示例#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();
    }