Beispiel #1
0
        private static void CreateRemoteGoToActions(PdfFixedDocument document, PdfFont font)
        {
            PdfPen   blackPen   = new PdfPen(new PdfRgbColor(0, 0, 0), 1);
            PdfBrush blackBrush = new PdfBrush();

            font.Size = 12;
            PdfStringAppearanceOptions sao = new PdfStringAppearanceOptions();

            sao.Brush = blackBrush;
            sao.Font  = font;
            PdfStringLayoutOptions slo = new PdfStringLayoutOptions();

            slo.HorizontalAlign = PdfStringHorizontalAlign.Center;
            slo.VerticalAlign   = PdfStringVerticalAlign.Middle;

            Random rnd = new Random();

            for (int i = 0; i < document.Pages.Count; i++)
            {
                int destinationPage = rnd.Next(document.Pages.Count);

                document.Pages[i].Graphics.DrawString("Go To Remote actions:", font, blackBrush, 400, 300);

                document.Pages[i].Graphics.DrawRectangle(blackPen, 400, 320, 200, 20);
                slo.X = 500;
                slo.Y = 330;
                document.Pages[i].Graphics.DrawString("Go To page " + (destinationPage + 1).ToString() + " in sample.pdf", sao, slo);

                // Create a link annotation on top of the widget.
                PdfLinkAnnotation link = new PdfLinkAnnotation();
                document.Pages[i].Annotations.Add(link);
                link.VisualRectangle = new PdfVisualRectangle(400, 320, 200, 20);

                // Create a GoToR action and attach it to the link.
                PdfPageNumberDestination pageDestination = new PdfPageNumberDestination();
                pageDestination.PageNumber = destinationPage;
                pageDestination.Left       = 0;
                pageDestination.Top        = 792;
                pageDestination.Zoom       = 0; // Keep current zoom
                PdfRemoteGoToAction remoteGoToAction = new PdfRemoteGoToAction();
                remoteGoToAction.FileName    = "sample.pdf";
                remoteGoToAction.Destination = pageDestination;
                link.Action = remoteGoToAction;
            }
        }
Beispiel #2
0
        private static void CreateRemoteGoToActions(PdfFixedDocument document, PdfFont font)
        {
            PdfPen blackPen = new PdfPen(new PdfRgbColor(0, 0, 0), 1);
            PdfBrush blackBrush = new PdfBrush();

            font.Size = 12;
            PdfStringAppearanceOptions sao = new PdfStringAppearanceOptions();
            sao.Brush = blackBrush;
            sao.Font = font;
            PdfStringLayoutOptions slo = new PdfStringLayoutOptions();
            slo.HorizontalAlign = PdfStringHorizontalAlign.Center;
            slo.VerticalAlign = PdfStringVerticalAlign.Middle;

            Random rnd = new Random();
            for (int i = 0; i < document.Pages.Count; i++)
            {
                int destinationPage = rnd.Next(document.Pages.Count);

                document.Pages[i].Graphics.DrawString("Go To Remote actions:", font, blackBrush, 400, 300);

                document.Pages[i].Graphics.DrawRectangle(blackPen, 400, 320, 200, 20);
                slo.X = 500;
                slo.Y = 330;
                document.Pages[i].Graphics.DrawString("Go To page " + (destinationPage + 1).ToString() + " in sample.pdf", sao, slo);

                // Create a link annotation on top of the widget.
                PdfLinkAnnotation link = new PdfLinkAnnotation();
                document.Pages[i].Annotations.Add(link);
                link.VisualRectangle = new PdfVisualRectangle(400, 320, 200, 20);

                // Create a GoToR action and attach it to the link.
                PdfPageNumberDestination pageDestination = new PdfPageNumberDestination();
                pageDestination.PageNumber = destinationPage;
                pageDestination.Left = 0;
                pageDestination.Top = 792;
                pageDestination.Zoom = 0; // Keep current zoom
                PdfRemoteGoToAction remoteGoToAction = new PdfRemoteGoToAction();
                remoteGoToAction.FileName = "sample.pdf";
                remoteGoToAction.Destination = pageDestination;
                link.Action = remoteGoToAction;
            }
        }