Esempio n. 1
0
        public static void Run()
        {
            // ExStart:HyperlinkNonPdfFile
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Hyperlinks();

            // Instantiate Pdf document object
            Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
            // Create a section in the Pdf
            Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();

            // Create text paragraph with the reference of a section
            Aspose.Pdf.Generator.Text text1 = new Aspose.Pdf.Generator.Text(sec1);

            // Add the text paragraph in the paragraphs collection of the section
            sec1.Paragraphs.Add(text1);

            // Add a text segment in the text paragraph
            Aspose.Pdf.Generator.Segment segment1 = text1.Segments.Add("this is a external file link");

            // Assign a new instance of hyperlink to hyperlink property of segment
            segment1.Hyperlink = new Aspose.Pdf.Generator.Hyperlink();

            // Set the link type of the text segment to File
            segment1.Hyperlink.LinkType = Aspose.Pdf.Generator.HyperlinkType.File;

            // Set the path of the external Non-Pdf file
            segment1.Hyperlink.LinkFile = dataDir + "aspose-logo.jpg";

            dataDir = dataDir + "HyperlinkNonPdfFile_out.pdf";
            // Save the Pdf
            pdf1.Save(dataDir);
            // ExEnd:HyperlinkNonPdfFile
        }
        public static void Run()
        {
            // ExStart:HyperlinkToWeb
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Hyperlinks();

            // Instantiate Pdf document object
            Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
            // Create a section in the Pdf
            Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
            // Create text paragraph with the reference of a section
            Aspose.Pdf.Generator.Text text2 = new Aspose.Pdf.Generator.Text(sec1);

            // Add the text paragraph in the paragraphs collection of the section
            sec1.Paragraphs.Add(text2);

            // Add a text segment in the text paragraph
            Aspose.Pdf.Generator.Segment segment2 = text2.Segments.Add("this is a web link");

            // Assign a new instance of hyperlink to hyperlink property of segment
            segment2.Hyperlink = new Aspose.Pdf.Generator.Hyperlink();

            // Set the link type of the text segment to Web
            segment2.Hyperlink.LinkType = Aspose.Pdf.Generator.HyperlinkType.Web;

            // Set the URL of the web location to create a web link for the segment
            segment2.Hyperlink.Url = "http://localhost/popup.htm";

            dataDir = dataDir + "HyperlinkToWeb_out_.pdf";
            // Save the Pdf
            pdf1.Save(dataDir);
            // ExEnd:HyperlinkToWeb
        }
        public static void Run()
        {
            // ExStart:HyperlinkPages
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Hyperlinks();

            // Instantiate Pdf document object
            Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
            // Create a section in the Pdf
            Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();

            // Create text paragraph with the reference of a section
            Aspose.Pdf.Generator.Text text1 = new Aspose.Pdf.Generator.Text(sec1);

            // Add the text paragraph in the paragraphs collection of the section
            sec1.Paragraphs.Add(text1);

            // Create a text segment
            Aspose.Pdf.Generator.Segment segment1 = new Aspose.Pdf.Generator.Segment();

            // Add a text segment in the text paragraph
            segment1 = text1.Segments.Add("this is a local link");

            // Set the text in the text segment to be underlined
            segment1.TextInfo.IsUnderline = true;

            // Set the link type of the text segment to Local
            segment1.Hyperlink.LinkType = Aspose.Pdf.Generator.HyperlinkType.Local;

            // Assign the id of the desired paragraph as a target id for the text segment
            segment1.Hyperlink.TargetID = "product1";

            // Create a text paragraph to be linked with the text segment
            Aspose.Pdf.Generator.Text text3 = new Aspose.Pdf.Generator.Text(sec1, "product 1 info ...");

            // Add the text paragraph to paragraphs collection of the section
            sec1.Paragraphs.Add(text3);

            // Set this paragraph to be the first so that it can be displayed in a separate
            // page in the document
            text3.IsFirstParagraph = true;

            // Set the id of this text paragraph to "product1"
            text3.ID = "product1";
            dataDir  = dataDir + "HyperlinkPages_out_.pdf";
            // Save the Pdf
            pdf1.Save(dataDir);
            // ExEnd:HyperlinkPages
        }
        public static void Run()
        {
            // ExStart:HyperlinkOtherPdf
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Hyperlinks();

            // Instantiate Pdf document object
            Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
            // Create a section in the Pdf
            Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();

            // Create text paragraph with the reference of a section
            Aspose.Pdf.Generator.Text text1 = new Aspose.Pdf.Generator.Text(sec1);

            // Add the text paragraph in the paragraphs collection of the section
            sec1.Paragraphs.Add(text1);

            // Create a text segment
            Aspose.Pdf.Generator.Segment segment1 = new Aspose.Pdf.Generator.Segment();

            // Add a text segment in the text paragraph
            segment1 = text1.Segments.Add("this is a pdf link");

            // Set the text in the segment to be underlined
            segment1.TextInfo.IsUnderline = true;

            // Set the link type of the text segment to Pdf
            segment1.Hyperlink.LinkType = Aspose.Pdf.Generator.HyperlinkType.Pdf;

            // Set the path of the external document
            segment1.Hyperlink.LinkFile = dataDir + "input.pdf";

            // Set the page number of the document to which the link is to be created
            segment1.Hyperlink.LinkPageNumber = 2;

            dataDir = dataDir + "HyperlinkOtherPdf_out.pdf";
            // Save the Pdf
            pdf1.Save(dataDir);
            // ExEnd:HyperlinkOtherPdf
        }