Exemplo n.º 1
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);
        Image      image = new Image(pdf, fis, ImageType.PNG);

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

        pdf.Close();
    }