コード例 #1
0
ファイル: Actions.cs プロジェクト: littlefeihu/checktask
        private static void CreateLaunchActions(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;

            for (int i = 0; i < document.Pages.Count; i++)
            {
                document.Pages[i].Graphics.DrawString("Launch actions:", font, blackBrush, 400, 360);

                document.Pages[i].Graphics.DrawRectangle(blackPen, 400, 380, 200, 20);
                slo.X = 500;
                slo.Y = 390;
                document.Pages[i].Graphics.DrawString("Launch samples explorer", 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, 380, 200, 20);

                // Create a launch action and attach it to the link.
                PdfLaunchAction launchAction = new PdfLaunchAction();
                launchAction.FileName = "Xfinium.Pdf.SamplesExplorer.Win.exe";
                link.Action           = launchAction;
            }
        }
コード例 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            //Create a new PDF document and add a page to it
            PdfDocument doc  = new PdfDocument();
            PdfPageBase page = doc.Pages.Add();

            //Create a PDF Launch Action
            PdfLaunchAction launchAction = new PdfLaunchAction("..\\..\\..\\..\\..\\..\\Data\\text.txt");

            //Create a PDF Action Annotation with the PDF Launch Action
            string          text = "Click here to open file";
            PdfTrueTypeFont font = new PdfTrueTypeFont(new Font("Arial", 13f));
            RectangleF      rect = new RectangleF(50, 50, 230, 15);

            page.Canvas.DrawString(text, font, PdfBrushes.ForestGreen, rect);
            PdfActionAnnotation annotation = new PdfActionAnnotation(rect, launchAction);

            //Add the PDF Action Annotation to page
            (page as PdfNewPage).Annotations.Add(annotation);


            String result = "AddPdfLaunchAction_out.pdf";

            //Save the document
            doc.SaveToFile(result);
            //Launch the Pdf file
            PDFDocumentViewer(result);
        }
コード例 #3
0
ファイル: Actions.cs プロジェクト: baitun/BGUEP-Journal
        private static void CreateLaunchActions(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;

            for (int i = 0; i < document.Pages.Count; i++)
            {
                document.Pages[i].Graphics.DrawString("Launch actions:", font, blackBrush, 400, 360);

                document.Pages[i].Graphics.DrawRectangle(blackPen, 400, 380, 200, 20);
                slo.X = 500;
                slo.Y = 390;
                document.Pages[i].Graphics.DrawString("Launch samples explorer", 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, 380, 200, 20);

                // Create a launch action and attach it to the link.
                PdfLaunchAction launchAction = new PdfLaunchAction();
                launchAction.FileName = "Xfinium.Pdf.SamplesExplorer.Win.exe";
                link.Action = launchAction;
            }
        }