예제 #1
0
        public static void Main(string[] args)
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");

            // Create directory if it is not already present.
            bool IsExists = System.IO.Directory.Exists(dataDir);
            if (!IsExists)
                System.IO.Directory.CreateDirectory(dataDir);

            //Instantiate a PDF Object
            Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();

            //Add a section into the pdf document
            Aspose.Pdf.Generator.Section section1 = pdf.Sections.Add();

            // create a sample text paragraph
            Aspose.Pdf.Generator.Text text1 = new Aspose.Pdf.Generator.Text("This is a test for XMP Metadata");
            // Add text paragraph to paragraphs collection of section object
            section1.Paragraphs.Add(text1);

            // create XmpMetaData object
            pdf.XmpMetadata = new Aspose.Pdf.Generator.XmpMetadata();

            //core properties
            pdf.XmpMetadata.AddCreationDate(System.DateTime.Now.ToString());

            //user properties
            pdf.XmpMetadata.AddUserProperty("xmlns:dc=\"http://purl.org/dc/elements/1.1/\"", "dc:contributor", "Aspose");

            //Save Pdf Document
            pdf.Save(dataDir+ "Aspose.pdf");
        }
예제 #2
0
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Paragraphs();
            // Create directory if it is not already present.
            bool IsExists = System.IO.Directory.Exists(dataDir);

            if (!IsExists)
            {
                System.IO.Directory.CreateDirectory(dataDir);
            }

            //Instantiate Pdf object by calling its empty constructor
            Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();

            //Add a new section to the Pdf object
            Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();

            //Create a text paragraph with the reference of a section, sec1
            Aspose.Pdf.Generator.Text text3 = new Aspose.Pdf.Generator.Text(sec1, "product 1 info ...");

            //Add the text paragraph in the section
            sec1.Paragraphs.Add(text3);

            //Set the text paragraph to be the first paragraph among the other ones
            text3.IsFirstParagraph = true;

            //Assign and ID to the text paragraph
            text3.ID = "product1";

            // save the resultant PDF
            pdf1.Save(dataDir + "ParaID.pdf");
        }
예제 #3
0
        public static void Main(string[] args)
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");

             // Create directory if it is not already present.
            bool IsExists = System.IO.Directory.Exists(dataDir);
            if (!IsExists)
                System.IO.Directory.CreateDirectory(dataDir);

            //Instantiate Pdf object by calling its empty constructor
            Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();

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

            //Create a new text paragraph with an initial text segment "Aspose"
            Aspose.Pdf.Generator.Text text1 = new Aspose.Pdf.Generator.Text(sec1,"Aspose");

            //Add the text paragraph to the section
            sec1.Paragraphs.Add(text1);

            //Create a new text segment into the text paragraph
            Aspose.Pdf.Generator.Segment seg2 = text1.Segments.Add("TM");

            //Set the vertical alignment of text segment "seg2" to Topline by setting
            //IsBaseline property  ot seg2.TextInfo to true
            seg2.TextInfo.IsBaseline=false;
            // set the font size information for the segment
            seg2.TextInfo.FontSize = 5;

            //Save the Pdf
            pdf1.Save(dataDir+ "AsposeOutput.pdf");
        }
예제 #4
0
        public static void Run()
        {
            // ExStart:SetTextBackgroundColor
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Text();

            // Instantiate Pdf instance by calling its empty constructor
            Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();

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


            // Create a text paragraph
            Aspose.Pdf.Generator.Text text1 = new Aspose.Pdf.Generator.Text(sec1, "Hello Aspose.Pdf");

            // Set the BackgroundColor of the text paragraph to Red
            text1.TextInfo.BackgroundColor = new Aspose.Pdf.Generator.Color("Red");

            // Add the text paragraph to the section
            sec1.Paragraphs.Add(text1);

            // Save the Pdf
            pdf1.Save(dataDir + "SetTextBackgroundColor_out.pdf");
            // ExEnd:SetTextBackgroundColor
        }
예제 #5
0
        public static void Run()
        {
            // ExStart:SetPassword
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_SecurityFeatures();

            // Instantiate Pdf instance by calling its empty constructor
            Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();

            // Assign a security instance to Pdf object
            pdf1.Security = new Aspose.Pdf.Generator.Security();

            // Set the master password for the PDF document
            pdf1.Security.MasterPassword = "******";

            // Set the user password for the PDF document
            pdf1.Security.UserPassword = "******";

            // Add a section in the Pdf
            Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();

            // Create a text paragraph
            Aspose.Pdf.Generator.Text text1 = new Aspose.Pdf.Generator.Text(sec1, "this is text content");

            // Set the top maring of text paragraph to 30
            text1.Margin.Top = 30;

            // Add the text paragraph to the section
            sec1.Paragraphs.Add(text1);
            dataDir = dataDir + "SetPassword_out.pdf";
            // Save the Pdf
            pdf1.Save(dataDir);
            // ExEnd:SetPassword
        }
예제 #6
0
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Sections();

            // Instantiate a PDF Object
            Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();

            // Add a section into the pdf document
            Aspose.Pdf.Generator.Section section1 = pdf.Sections.Add();
            // ExStart:SetHeaderAndFooter
            // Instantiate HeaderFooter object and pass the Section reference in which
            // The header or footer is to be added
            Aspose.Pdf.Generator.HeaderFooter hf1 = new Aspose.Pdf.Generator.HeaderFooter(section1);

            // Set the header of odd pages of the PDF document
            section1.OddHeader = hf1;

            // Set the header of even pages of the PDF document
            section1.EvenHeader = hf1;

            // Instantiate a Text paragraph that will store the content to show as header
            Aspose.Pdf.Generator.Text text = new Aspose.Pdf.Generator.Text(hf1, "header");

            // Add the text object to the Paragraphs collection of HeaderFooter object to
            // Display header on the pages of PDF document
            hf1.Paragraphs.Add(text);
            // ExEnd:SetHeaderAndFooter
            dataDir = dataDir + "SetHeaderAndFooter_out.pdf";

            // Save Pdf Document
            pdf.Save(dataDir);

            Console.WriteLine("\nHeader and footer setup successfully.\nFile saved at " + dataDir);
        }
예제 #7
0
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Paragraphs();
            // Create directory if it is not already present.
            bool IsExists = System.IO.Directory.Exists(dataDir);
            if (!IsExists)
                System.IO.Directory.CreateDirectory(dataDir);

            //Instantiate Pdf object by calling its empty constructor
            Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf(); 

            //Add a new section to the Pdf object
            Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add(); 

            //Create a text paragraph with the reference of a section, sec1
            Aspose.Pdf.Generator.Text text3 = new Aspose.Pdf.Generator.Text(sec1, "product 1 info ...");

            //Add the text paragraph in the section
            sec1.Paragraphs.Add(text3);

            //Set the text paragraph to be the first paragraph among the other ones
            text3.IsFirstParagraph = true;

            //Assign and ID to the text paragraph
            text3.ID = "product1";

            // save the resultant PDF
            pdf1.Save(dataDir+ "ParaID.pdf");
            
        }
예제 #8
0
        public static void Run()
        {
            try
            {
                // ExStart:HyperlinkTags
                // The path to the documents directory.
                string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Text();

                // Instantiate a pdf document
                Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();

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

                // Create a string variable with text containing hyperlink tag
                string string1 = "<a href=\"http:// Www.aspose.com/\">This is a test</a>";

                // Create text paragraph containing HTML hyperlink tag
                Aspose.Pdf.Generator.Text text1 = new Aspose.Pdf.Generator.Text(string1);
                text1.IsHtmlTagSupported = true;

                // Add the text paragraph containing HTML text to the section
                sec1.Paragraphs.Add(text1);

                // Save the document
                pdf1.Save(dataDir + "HyperlinkTags_out.pdf");
                // ExEnd:HyperlinkTags
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Text();

            // Create directory if it is not already present.
            bool IsExists = System.IO.Directory.Exists(dataDir);
            if (!IsExists)
                System.IO.Directory.CreateDirectory(dataDir);

            //Instantiate Pdf instance by calling its empty constructor
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();

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

//Create a text paragraph
Aspose.Pdf.Generator.Text text1 = new Aspose.Pdf.Generator.Text(sec1,"Hello Aspose.Pdf");

//Set the BackgroundColor of the text paragraph to Red
text1.TextInfo.BackgroundColor=new Aspose.Pdf.Generator.Color("Red");

//Add the text paragraph to the section
sec1.Paragraphs.Add(text1);

//Save the Pdf
pdf1.Save(dataDir+ "AsposeOutput.pdf");
            
            
        }
        public static void Run()
        {
            // ExStart:AddingXMPMetaData
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_WorkingDocuments();
                       
            // Instantiate a PDF Object 
            Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();

            // Add a section into the pdf document
            Aspose.Pdf.Generator.Section section1 = pdf.Sections.Add();

            // Create a sample text paragraph
            Aspose.Pdf.Generator.Text text1 = new Aspose.Pdf.Generator.Text("This is a test for XMP Metadata");
            // Add text paragraph to paragraphs collection of section object
            section1.Paragraphs.Add(text1);

            // Create XmpMetaData object
            pdf.XmpMetadata = new Aspose.Pdf.Generator.XmpMetadata();

            // Core properties
            pdf.XmpMetadata.AddCreationDate(System.DateTime.Now.ToString());

            // User properties
            pdf.XmpMetadata.AddUserProperty("xmlns:dc=\"http:// Purl.org/dc/elements/1.1/\"", "dc:contributor", "Aspose");

            dataDir = dataDir + "AddingXMPMetaData_out.pdf";
            // Save Pdf Document
            pdf.Save(dataDir);
            // ExEnd:AddingXMPMetaData
            Console.WriteLine("\nXMP metadata setup successfully.\nFile saved at " + dataDir);
            
        }
예제 #11
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
        }
예제 #12
0
        public static void Run()
        {
            try
            {
                // ExStart:SuperSubscript
                // The path to the documents directory.
                string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Text();

                // Instantiate a pdf document
                Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();

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

                // Create a string variable with html text containing Sub & Sup tags
                string string1 = "<FONT face=\"Times New Roman\" size=18>HARBIN<sup>[1234]</sup> : An unexpected stoppage of water<sub>[abcd]</sub>  supply sparked <sup> rumours of a contaminated river</sup> and led to a run on city <sub>supermarkets storing bottled water</sub> yesterday.</FONT>";

                // Create text paragraph containing HTML text
                Aspose.Pdf.Generator.Text text1 = new Aspose.Pdf.Generator.Text(string1);
                text1.IsHtmlTagSupported = true;

                // Add the text paragraph containing HTML text to the section
                sec1.Paragraphs.Add(text1);

                // Save the document
                pdf1.Save(dataDir + "SuperSubscript_out.pdf");
                // ExEnd:SuperSubscript
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
        public static void Run()
        {
            // ExStart:SetTextBackgroundColor
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Text();
         
            // Instantiate Pdf instance by calling its empty constructor
            Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();

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


            // Create a text paragraph
            Aspose.Pdf.Generator.Text text1 = new Aspose.Pdf.Generator.Text(sec1,"Hello Aspose.Pdf");

            // Set the BackgroundColor of the text paragraph to Red
            text1.TextInfo.BackgroundColor=new Aspose.Pdf.Generator.Color("Red");

            // Add the text paragraph to the section
            sec1.Paragraphs.Add(text1);

            // Save the Pdf
            pdf1.Save(dataDir + "SetTextBackgroundColor_out.pdf");
            // ExEnd:SetTextBackgroundColor
        }
        public static void Run()
        {
            // ExStart:InlineParagraph
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Text();

            // Instantiate Pdf instance by calling its empty constructor
            Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
            // Create section object and add it to sections collection of PDF
            Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();

            // Create a text object
            Aspose.Pdf.Generator.Text text1 = new Aspose.Pdf.Generator.Text();
            // Add text object to paragraphs collection of section
            sec1.Paragraphs.Add(text1);
            // Add sample text to segments collection of text object
            text1.Segments.Add("This is a test for inline");
            // Create segment 2 and add it to segements collection of text object
            Aspose.Pdf.Generator.Segment seg2 = text1.Segments.Add();

            // Create a Image object to contain logo gif.
            Aspose.Pdf.Generator.Image img1 = new Aspose.Pdf.Generator.Image();
            // Specify the image file path
            img1.ImageInfo.File = dataDir + "aspose-logo.jpg";
            // Indicate seg2's InlineParagraph is a image.
            seg2.InlineParagraph = img1;
            dataDir = dataDir + "InlineImage_out.pdf";
            // Create the result PDF Document
            pdf1.Save(dataDir);
            // ExEnd:InlineParagraph
        }
예제 #15
0
        public static void Run()
        {
            // ExStart:SetEncryption
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_SecurityFeatures();

            // Instantiate Pdf instance by calling its empty constructor
            Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();

            // Assign a security instance to Pdf object
            pdf1.Security = new Aspose.Pdf.Generator.Security();

            // Set encryption level to 128 bits
            pdf1.Security.Is128BitsEncrypted = true;

            // Add a section in the Pdf
            Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();

            // Create a text paragraph
            Aspose.Pdf.Generator.Text text1 = new Aspose.Pdf.Generator.Text(sec1, "this is text content");

            // Set the top maring of text paragraph to 30
            text1.Margin.Top = 30;

            // Add the text paragraph to the section
            sec1.Paragraphs.Add(text1);

            dataDir = dataDir + "SetEncryption_out.pdf";
            // Save the Pdf
            pdf1.Save(dataDir);
            // ExEnd:SetEncryption
        }
예제 #16
0
        public static void Main(string[] args)
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");

            // Instantiate an object PDF class
            Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();

            // add the section to PDF document sections collection
            Aspose.Pdf.Generator.Section section = pdf.Sections.Add();

            // Read the contents of HTML file into StreamReader object
            StreamReader r = File.OpenText(dataDir + "Aspose.htm");

            //Create text paragraphs containing HTML text
            Aspose.Pdf.Generator.Text text2 = new Aspose.Pdf.Generator.Text(section, r.ReadToEnd());

            // enable the property to display HTML contents within their own formatting
            text2.IsHtmlTagSupported = true;

            //Add the text paragraphs containing HTML text to the section
            section.Paragraphs.Add(text2);

            // Specify the URL which serves as images database
            //pdf.HtmlInfo.ImgUrl = "D:/pdftest/MemoryStream/";

            //Save the pdf document
            pdf.Save(dataDir + "HTML2pdf.pdf");
        }
예제 #17
0
        public static void Run()
        {
            
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Text();

            // Instantiate Pdf instance by calling it empty constructor
            Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();

            // Create a section in the Pdf object
            Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
            // ExStart:PFMFont
            // Create a text object in a section
            Aspose.Pdf.Generator.Text t1 = new Aspose.Pdf.Generator.Text(sec1, "Arial Bold MT");

            // Set the font name of a segment in the text object
            t1.Segments[0].TextInfo.FontName = "Arial-BoldMT";

            // Set the PFM file for the text segment 
            t1.Segments[0].TextInfo.FontPfmFile = "_AB_____.PFM";

            // Set the font encoding file for the text segment
            t1.Segments[0].TextInfo.FontEncodingFile = @"CP1250.txt";

            // Set the font encoding name of the text segment
            t1.Segments[0].TextInfo.FontEncoding = "cp1250";
            // ExEnd:PFMFont
            dataDir = dataDir + "PFMFont_out.pdf";
            // Create the result PDF Document
            pdf1.Save(dataDir);
            
        }
        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           
        }
예제 #19
0
        public static void Main(string[] args)
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");

            // Instantiate an object PDF class
            Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();

            // add the section to PDF document sections collection
            Aspose.Pdf.Generator.Section section = pdf.Sections.Add();

            // Read the contents of HTML file into StreamReader object
            StreamReader r = File.OpenText(dataDir + "Aspose.htm");

            //Create text paragraphs containing HTML text
            Aspose.Pdf.Generator.Text text2 = new Aspose.Pdf.Generator.Text(section, r.ReadToEnd());

            // enable the property to display HTML contents within their own formatting
            text2.IsHtmlTagSupported = true;

            //Add the text paragraphs containing HTML text to the section
            section.Paragraphs.Add(text2);

            // Specify the URL which serves as images database
            //pdf.HtmlInfo.ImgUrl = "D:/pdftest/MemoryStream/";

            //Save the pdf document
            pdf.Save(dataDir + "HTML2pdf.pdf");
        }
예제 #20
0
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Text();

            // Create directory if it is not already present.
            bool IsExists = System.IO.Directory.Exists(dataDir);
            if (!IsExists)
                System.IO.Directory.CreateDirectory(dataDir);

            //Instantiate Pdf instance by calling it empty constructor
            Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();
            //Create a section in the Pdf object
            pdf.Sections.Add();

            pdf.IsTruetypeFontMapCached = true;
            //Specify the location where to save TruetypeFontMap.xml
            pdf.TruetypeFontMapPath = dataDir+ "" ;

            //Create a text object and pass the string object carrying arabic text in it
            Aspose.Pdf.Generator.Text text1 = new Aspose.Pdf.Generator.Text();
            //Create a segment and add it to segments collection of text object
            Aspose.Pdf.Generator.Segment seg0 = text1.Segments.Add();
            //specify contents for segment
            seg0.Content = "أسبوز هو بائع عنصر ال";
            Aspose.Pdf.Generator.Segment seg1 = text1.Segments.Add();
            seg1.Content = ".NET";
            Aspose.Pdf.Generator.Segment seg2 = text1.Segments.Add();
            seg2.Content = "البارز";

            //Enable text alignment from right to left
            seg0.TextInfo.IsRightToLeft = true;
            seg1.TextInfo.IsRightToLeft = false;         //default
            seg2.TextInfo.IsRightToLeft = true;

            //Enable unicode character set for the text segment
            seg0.TextInfo.IsUnicode = true;
            seg1.TextInfo.IsUnicode = true;
            seg2.TextInfo.IsUnicode = true;

            //Set Font Name
            seg0.TextInfo.FontName = "Times New Roman";
            seg1.TextInfo.FontName = "Times New Roman";
            seg2.TextInfo.FontName = "Times New Roman";
            //Set font size
            seg0.TextInfo.FontSize = 14;
            seg1.TextInfo.FontSize = 14;
            seg2.TextInfo.FontSize = 14;

            //Align text to right hand side using AlignmentType enumeration    
            //Make the text right aligned(The meaning of Alignment.Left and AlignmentType.Right are //exchanged when processing RTL language).
            text1.TextInfo.Alignment = Aspose.Pdf.Generator.AlignmentType.Left;

            pdf.Sections[0].Paragraphs.Add(text1);
            pdf.IsRtlInSegmentMode = true;         //default

            pdf.Save(dataDir+"AsposeOutput.pdf");
            
            
        }
예제 #21
0
        public static void Run()
        {
            // ExStart:AddingXMPMetaData
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_WorkingDocuments();

            // Instantiate a PDF Object
            Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();

            // Add a section into the pdf document
            Aspose.Pdf.Generator.Section section1 = pdf.Sections.Add();

            // Create a sample text paragraph
            Aspose.Pdf.Generator.Text text1 = new Aspose.Pdf.Generator.Text("This is a test for XMP Metadata");
            // Add text paragraph to paragraphs collection of section object
            section1.Paragraphs.Add(text1);

            // Create XmpMetaData object
            pdf.XmpMetadata = new Aspose.Pdf.Generator.XmpMetadata();

            // Core properties
            pdf.XmpMetadata.AddCreationDate(System.DateTime.Now.ToString());

            // User properties
            pdf.XmpMetadata.AddUserProperty("xmlns:dc=\"http://purl.org/dc/elements/1.1/\"", "dc:contributor", "Aspose");

            dataDir = dataDir + "AddingXMPMetaData_out_.pdf";
            // Save Pdf Document
            pdf.Save(dataDir);
            // ExEnd:AddingXMPMetaData
            Console.WriteLine("\nXMP metadata setup successfully.\nFile saved at " + dataDir);
        }
예제 #22
0
        public static void Run()
        {
            // ExStart:Render
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Paragraphs();
           
            // Instantiate Pdf instance by calling its empty constructor
            Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();

            // Create a section in the Pdf document and add a text paragraph in the section
            Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();            
            sec1.Paragraphs.Add(new Aspose.Pdf.Generator.Text("page 1"));

            // Create another text paragraph that has to be rendered
            Aspose.Pdf.Generator.Text t2 = new Aspose.Pdf.Generator.Text("page2");

            // Set the IsFirstParagraph property of the text paragraph to true to render it to a new page           
            t2.IsFirstParagraph = true;

            // Add the text paragraph to be rendered to the section
            sec1.Paragraphs.Add(t2);

            dataDir = dataDir + "RenderParagraph_out.pdf";
            // Save the Pdf document
            pdf1.Save(dataDir);
            // ExEnd:Render   
            Console.WriteLine("\nParagraph renders successfully.\nFile saved at " + dataDir);
        }
예제 #23
0
        public static void Run()
        {
            // ExStart:AssignID
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Paragraphs();

            // Instantiate Pdf object by calling its empty constructor and add a new section to the Pdf object
            Aspose.Pdf.Generator.Pdf     pdf1 = new Aspose.Pdf.Generator.Pdf();
            Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();

            // Create a text paragraph with the reference of a section, sec1 and add the text paragraph in the section
            Aspose.Pdf.Generator.Text text3 = new Aspose.Pdf.Generator.Text(sec1, "product 1 info ...");
            sec1.Paragraphs.Add(text3);

            // Set the text paragraph to be the first paragraph among the other ones
            text3.IsFirstParagraph = true;

            // Assign and ID to the text paragraph
            text3.ID = "product1";

            dataDir = dataDir + "AssignID_out.pdf";
            // Save the resultant PDF
            pdf1.Save(dataDir);
            // ExEnd:AssignID
            Console.WriteLine("\nAn id assigned successfully to a paragraph.\nFile saved at " + dataDir);
        }
예제 #24
0
        public static void TrueTypeBoldFont()
        {
          
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Text();

            // Instantiate Pdf instance by calling it empty constructor
            Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();

            // Create a section in the Pdf object
            Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
            // ExStart:TrueTypeBoldFont
            // Create a text object in the section
            Aspose.Pdf.Generator.Text t1 = new Aspose.Pdf.Generator.Text(sec1, "Courier New Bold font");

            // Set font name of a specific text segment to courier new
            t1.Segments[0].TextInfo.FontName = "Courier New";

            // Set the font to bold
            t1.Segments[0].TextInfo.IsTrueTypeFontBold = true;
            // ExEnd:TrueTypeBoldFont
            dataDir = dataDir + "TrueTypeBoldFont_out.pdf";
            // Create the result PDF Document
            pdf1.Save(dataDir);
            
        }
예제 #25
0
        public static void Main(string[] args)
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");

            // Create directory if it is not already present.
            bool IsExists = System.IO.Directory.Exists(dataDir);
            if (!IsExists)
                System.IO.Directory.CreateDirectory(dataDir);

            //Instantiate Pdf instance by calling its empty constructor
            Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();

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

            //Add a text paragraph in the section
            sec1.Paragraphs.Add(new Aspose.Pdf.Generator.Text("page 1"));

            //Create another text paragraph that has to be rendered
            Aspose.Pdf.Generator.Text t2 = new Aspose.Pdf.Generator.Text("page2");

            //Set the IsFirstParagraph property of the text paragraph to true
            //to render it to a new page
            t2.IsFirstParagraph = true;

            //Add the text paragraph to be rendered to the section
            sec1.Paragraphs.Add(t2);

            //Save the Pdf document
            pdf1.Save(dataDir+ "HelloWorld.pdf");
        }
예제 #26
0
        public static void Run()
        {
            // ExStart:CreatePdf
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_UtilityFeatures();

            // Create a file stream to create the PDF document
            FileStream fs = new FileStream( dataDir +  "SingleSeg-d_out.pdf", FileMode.Create);

            // Instantiate the Pdf instance and pass the file stream object to its constructor
            Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf(fs);

            // Add a section to the PDF document
            Aspose.Pdf.Generator.Section sec1 = pdf.Sections.Add();

            // Add 1000 text paragraphs to the section
            for (int i = 0; i < 1000; i++)
            {
                Aspose.Pdf.Generator.Text t = new Aspose.Pdf.Generator.Text("hello world hello world hello " + i.ToString());
                sec1.AddParagraph(t);
            }

            // Close the Pdf. This method is used only for direct file mode
            pdf.Close(); 
            // ExEnd:CreatePdf           
        }
        public static void FontsEmbeddingUsingHTML()
        {
            // ExStart:FontsEmbeddingUsingHTML 
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_TechnicalArticles();

            // Instantiate a pdf document
            Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();

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

            // Create string variables with text containing html tags
            string s = "<html><body><font isUnicode='true' face='Bete Noir NF' size=18><i>Sample text </i>with Custome font Embedded </font><br><font isUnicode='true' face='Courier New' size=10><s>Sample Text </s>in <u>Courier New</u> font</font></body></html>";

            // Create text paragraphs containing HTML text
            Aspose.Pdf.Generator.Text t1 = new Aspose.Pdf.Generator.Text(s);

            // Enable the HTML tag support property
            t1.IsHtmlTagSupported = true;

            // Add the text paragraphs containing HTML text to the section
            sec1.Paragraphs.Add(t1);

            // Save the pdf document
            pdf1.Save( dataDir + "inLineFormated_HtmlSuported_out.pdf");
            // ExEnd:FontsEmbeddingUsingHTML 
        }
예제 #28
0
        public static void Main(string[] args)
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");

            // Create directory if it is not already present.
            bool IsExists = System.IO.Directory.Exists(dataDir);

            if (!IsExists)
            {
                System.IO.Directory.CreateDirectory(dataDir);
            }

            //Instantiate Pdf instance by calling its empty constructor
            Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();

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

//Create a text paragraph
            Aspose.Pdf.Generator.Text text1 = new Aspose.Pdf.Generator.Text(sec1, "Hello Aspose.Pdf");

//Set the BackgroundColor of the text paragraph to Red
            text1.TextInfo.BackgroundColor = new Aspose.Pdf.Generator.Color("Red");

//Add the text paragraph to the section
            sec1.Paragraphs.Add(text1);

//Save the Pdf
            pdf1.Save(dataDir + "AsposeOutput.pdf");
        }
        public static void Run()
        {
            // ExStart:SetEncryption
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_SecurityFeatures();

            // Instantiate Pdf instance by calling its empty constructor
            Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();

            // Assign a security instance to Pdf object
            pdf1.Security = new Aspose.Pdf.Generator.Security();

            // Set encryption level to 128 bits
            pdf1.Security.Is128BitsEncrypted = true;

            // Add a section in the Pdf
            Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();

            // Create a text paragraph                           
            Aspose.Pdf.Generator.Text text1 = new Aspose.Pdf.Generator.Text(sec1,"this is text content");

            // Set the top maring of text paragraph to 30
            text1.Margin.Top = 30;

            // Add the text paragraph to the section
            sec1.Paragraphs.Add(text1);

            dataDir = dataDir + "SetEncryption_out.pdf";
            // Save the Pdf                           
            pdf1.Save(dataDir);
            // ExEnd:SetEncryption           
        }
예제 #30
0
        public static void Unicode()
        {
            // ExStart:Unicode
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Text();

            // Instantiate Pdf instance by calling it empty constructor
            Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();
            // Set the property to make your application run faster. It will help load the Truetype font faster
            pdf.IsTruetypeFontMapCached = true;
            // Create a section in the Pdf object
            Aspose.Pdf.Generator.Section sec1 = pdf.Sections.Add();

            // To assign a unicode character by it's coding
            Aspose.Pdf.Generator.Text t1 = new Aspose.Pdf.Generator.Text(((char)0x25a0).ToString());
            // Specify the font face name for first segment in text object
            t1.Segments[0].TextInfo.FontName = "Times New Roman";
            // Specify that first segment in text is UniCode
            t1.Segments[0].TextInfo.IsUnicode = true;
            // Add text to paragraphs collection of section object
            sec1.Paragraphs.Add(t1);
            // Save the PDF document
            pdf.Save(dataDir + "Unicode_out.pdf");
            // ExEnd:Unicode
        }
예제 #31
0
        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
        }
예제 #32
0
        public static void Run()
        {
            // ExStart:AssignID
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Paragraphs();

            // Instantiate Pdf object by calling its empty constructor and add a new section to the Pdf object
            Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();             
            Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();

            // Create a text paragraph with the reference of a section, sec1 and add the text paragraph in the section
            Aspose.Pdf.Generator.Text text3 = new Aspose.Pdf.Generator.Text(sec1, "product 1 info ...");    
            sec1.Paragraphs.Add(text3);

            // Set the text paragraph to be the first paragraph among the other ones
            text3.IsFirstParagraph = true;

            // Assign and ID to the text paragraph
            text3.ID = "product1";

            dataDir = dataDir + "AssignID_out.pdf";
            // Save the resultant PDF
            pdf1.Save(dataDir);
            // ExEnd:AssignID   
            Console.WriteLine("\nAn id assigned successfully to a paragraph.\nFile saved at " + dataDir);
        }
예제 #33
0
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Text();

            // Instantiate Pdf instance by calling it empty constructor
            Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();

            // Create a section in the Pdf object
            Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
            // ExStart:PFMFont
            // Create a text object in a section
            Aspose.Pdf.Generator.Text t1 = new Aspose.Pdf.Generator.Text(sec1, "Arial Bold MT");

            // Set the font name of a segment in the text object
            t1.Segments[0].TextInfo.FontName = "Arial-BoldMT";

            // Set the PFM file for the text segment
            t1.Segments[0].TextInfo.FontPfmFile = "_AB_____.PFM";

            // Set the font encoding file for the text segment
            t1.Segments[0].TextInfo.FontEncodingFile = @"CP1250.txt";

            // Set the font encoding name of the text segment
            t1.Segments[0].TextInfo.FontEncoding = "cp1250";
            // ExEnd:PFMFont
            dataDir = dataDir + "PFMFont_out_.pdf";
            // Create the result PDF Document
            pdf1.Save(dataDir);
        }
예제 #34
0
        public static void Run()
        {
            // ExStart:Render
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Paragraphs();

            // Instantiate Pdf instance by calling its empty constructor
            Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();

            // Create a section in the Pdf document and add a text paragraph in the section
            Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
            sec1.Paragraphs.Add(new Aspose.Pdf.Generator.Text("page 1"));

            // Create another text paragraph that has to be rendered
            Aspose.Pdf.Generator.Text t2 = new Aspose.Pdf.Generator.Text("page2");

            // Set the IsFirstParagraph property of the text paragraph to true to render it to a new page
            t2.IsFirstParagraph = true;

            // Add the text paragraph to be rendered to the section
            sec1.Paragraphs.Add(t2);

            dataDir = dataDir + "RenderParagraph_out.pdf";
            // Save the Pdf document
            pdf1.Save(dataDir);
            // ExEnd:Render
            Console.WriteLine("\nParagraph renders successfully.\nFile saved at " + dataDir);
        }
        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           
        }
예제 #36
0
        public static void Run()
        {
            // ExStart:CreatePdf
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_UtilityFeatures();

            // Create a file stream to create the PDF document
            FileStream fs = new FileStream( dataDir +  "SingleSeg-d_out_.pdf", FileMode.Create);

            // Instantiate the Pdf instance and pass the file stream object to its constructor
            Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf(fs);

            // Add a section to the PDF document
            Aspose.Pdf.Generator.Section sec1 = pdf.Sections.Add();

            // Add 1000 text paragraphs to the section
            for (int i = 0; i < 1000; i++)
            {
                Aspose.Pdf.Generator.Text t = new Aspose.Pdf.Generator.Text("hello world hello world hello " + i.ToString());
                sec1.AddParagraph(t);
            }

            // Close the Pdf. This method is used only for direct file mode
            pdf.Close();
            // ExEnd:CreatePdf
        }
예제 #37
0
        public static void Main(string[] args)
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");

            // Create directory if it is not already present.
            bool IsExists = System.IO.Directory.Exists(dataDir);

            if (!IsExists)
            {
                System.IO.Directory.CreateDirectory(dataDir);
            }

            //Instantiate Pdf instance by calling it empty constructor
            Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();

            //Create a text object
            Aspose.Pdf.Generator.Text text1 = new Aspose.Pdf.Generator.Text("This #$TAB is a example for custom TAB stop positions.");

            //Assign an instance of TabStops to the TabStops property of text object
            text1.TabStops = new Aspose.Pdf.Generator.TabStops();

            //Call Add method of TabStops and pass a specified position as argument
            text1.TabStops.Add(150);

            //Call Add method with specified position and tab leader type as Dot
            text1.TabStops.Add(350, Aspose.Pdf.Generator.TabLeaderType.Dot);

            pdf.Save(dataDir + "Output.pdf");
        }
예제 #38
0
        public static void Main(string[] args)
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");

            // Create directory if it is not already present.
            bool IsExists = System.IO.Directory.Exists(dataDir);
            if (!IsExists)
                System.IO.Directory.CreateDirectory(dataDir);

            //Instantiate Pdf instance by calling it empty constructor
            Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();

            //Create a text object
            Aspose.Pdf.Generator.Text text1 = new Aspose.Pdf.Generator.Text("This #$TAB is a example for custom TAB stop positions.");

            //Assign an instance of TabStops to the TabStops property of text object
            text1.TabStops = new Aspose.Pdf.Generator.TabStops();

            //Call Add method of TabStops and pass a specified position as argument
            text1.TabStops.Add(150);

            //Call Add method with specified position and tab leader type as Dot
            text1.TabStops.Add(350, Aspose.Pdf.Generator.TabLeaderType.Dot);

            pdf.Save(dataDir + "Output.pdf");
        }
예제 #39
0
        public static void Main(string[] args)
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");

            // Create directory if it is not already present.
            bool IsExists = System.IO.Directory.Exists(dataDir);

            if (!IsExists)
            {
                System.IO.Directory.CreateDirectory(dataDir);
            }

            //Instantiate Pdf instance by calling its empty constructor
            Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();

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

            //Add a text paragraph in the section
            sec1.Paragraphs.Add(new Aspose.Pdf.Generator.Text("page 1"));

            //Create another text paragraph that has to be rendered
            Aspose.Pdf.Generator.Text t2 = new Aspose.Pdf.Generator.Text("page2");

            //Set the IsFirstParagraph property of the text paragraph to true
            //to render it to a new page
            t2.IsFirstParagraph = true;

            //Add the text paragraph to be rendered to the section
            sec1.Paragraphs.Add(t2);

            //Save the Pdf document
            pdf1.Save(dataDir + "HelloWorld.pdf");
        }
예제 #40
0
        public static void FontsEmbeddingUsingHTML()
        {
            // ExStart:FontsEmbeddingUsingHTML
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_TechnicalArticles();

            // Instantiate a pdf document
            Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();

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

            // Create string variables with text containing html tags
            string s = "<html><body><font isUnicode='true' face='Bete Noir NF' size=18><i>Sample text </i>with Custome font Embedded </font><br><font isUnicode='true' face='Courier New' size=10><s>Sample Text </s>in <u>Courier New</u> font</font></body></html>";

            // Create text paragraphs containing HTML text
            Aspose.Pdf.Generator.Text t1 = new Aspose.Pdf.Generator.Text(s);

            // Enable the HTML tag support property
            t1.IsHtmlTagSupported = true;

            // Add the text paragraphs containing HTML text to the section
            sec1.Paragraphs.Add(t1);

            // Save the pdf document
            pdf1.Save(dataDir + "inLineFormated_HtmlSuported_out.pdf");
            // ExEnd:FontsEmbeddingUsingHTML
        }
예제 #41
0
        public static void Run()
        {
            // ExStart:SetPassword
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_SecurityFeatures();

            // Instantiate Pdf instance by calling its empty constructor
            Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();

            // Assign a security instance to Pdf object
            pdf1.Security = new Aspose.Pdf.Generator.Security();

            // Set the master password for the PDF document
            pdf1.Security.MasterPassword="******";

            // Set the user password for the PDF document
            pdf1.Security.UserPassword="******";

            // Add a section in the Pdf
            Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();

            // Create a text paragraph
            Aspose.Pdf.Generator.Text text1 = new Aspose.Pdf.Generator.Text(sec1,"this is text content");

            // Set the top maring of text paragraph to 30
            text1.Margin.Top = 30;

            // Add the text paragraph to the section
            sec1.Paragraphs.Add(text1);
            dataDir = dataDir +"SetPassword_out.pdf";
            // Save the Pdf
            pdf1.Save(dataDir);
            // ExEnd:SetPassword           
        }
        public static void SecondApproach()
        {
            // ExStart:SecondApproach
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_TechnicalArticles();

            // Create a PDF object
            Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();

            Aspose.Pdf.Generator.Section sec1 = pdf.Sections.Add();
            // Create a text object
            Aspose.Pdf.Generator.Text t1 = new Aspose.Pdf.Generator.Text(sec1);
            // Create a Floating Box object that will hold image file
            Aspose.Pdf.Generator.FloatingBox TextFloatingBox1 = new Aspose.Pdf.Generator.FloatingBox(117, 21);
            // Specify the ZIndex value for TextFloatingBox
            TextFloatingBox1.ZIndex = 1;
            TextFloatingBox1.Left   = -4;
            TextFloatingBox1.Top    = -4;
            // Add Floating box to paragraphs collection of Section1
            sec1.Paragraphs.Add(TextFloatingBox1);

            // Add the text object to Paragraphs collection of FloatingBox
            TextFloatingBox1.Paragraphs.Add(t1);

            Aspose.Pdf.Generator.Segment seg1 = new Aspose.Pdf.Generator.Segment(t1);
            // Add the contents for Segment1
            seg1.Content = "paragraph 3 segment 1";
            // Specify the Font fore color for segement1
            seg1.TextInfo.Color = new Aspose.Pdf.Generator.Color("red");
            // Specify the font size information for segment1
            seg1.TextInfo.FontSize = 12;
            // Specify the value for Opacity of text. Default is 1.0. Use it for multilayer effect
            t1.Opacity = 0F;
            // Add the segment to segments collection of Text1
            t1.Segments.Add(seg1);

            // JPeg image cover the underlayer text
            Aspose.Pdf.Generator.Image image1 = new Aspose.Pdf.Generator.Image(sec1);
            image1.ImageInfo.File          = dataDir + "aspose-logo.jpg";
            image1.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Jpeg;

            // Create a Floating Box object that will hold image file
            Aspose.Pdf.Generator.FloatingBox ImageFloatingBox = new Aspose.Pdf.Generator.FloatingBox(117, 21);
            // Add Floating box to paragraphs collection of Section1
            sec1.Paragraphs.Add(ImageFloatingBox);

            // Specify the left margin of FloatingBox1
            ImageFloatingBox.Left = -4;
            // Specify the Top margin of FloatingBox1
            ImageFloatingBox.Top = -4;
            // Specify the ZIndex of ImageFloatingBox
            ImageFloatingBox.ZIndex = 2;
            // Add the image file to paragraphs collection of FloatingBox
            ImageFloatingBox.Paragraphs.Add(image1);

            // Save the reusltant PDF document
            pdf.Save(dataDir + @"Multilayer-2ndApproach_out_.pdf");
            // ExEnd:SecondApproach
        }
        public static void SecondApproach()
        {
            // ExStart:SecondApproach
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_TechnicalArticles();

            // Create a PDF object
            Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();

            Aspose.Pdf.Generator.Section sec1 = pdf.Sections.Add();
            // Create a text object 
            Aspose.Pdf.Generator.Text t1 = new Aspose.Pdf.Generator.Text(sec1);
            // Create a Floating Box object that will hold image file
            Aspose.Pdf.Generator.FloatingBox TextFloatingBox1 = new Aspose.Pdf.Generator.FloatingBox(117, 21);
            // Specify the ZIndex value for TextFloatingBox
            TextFloatingBox1.ZIndex = 1;
            TextFloatingBox1.Left = -4;
            TextFloatingBox1.Top = -4;
            // Add Floating box to paragraphs collection of Section1
            sec1.Paragraphs.Add(TextFloatingBox1);

            // Add the text object to Paragraphs collection of FloatingBox
            TextFloatingBox1.Paragraphs.Add(t1);

            Aspose.Pdf.Generator.Segment seg1 = new Aspose.Pdf.Generator.Segment(t1);
            // Add the contents for Segment1
            seg1.Content = "paragraph 3 segment 1";
            // Specify the Font fore color for segement1
            seg1.TextInfo.Color = new Aspose.Pdf.Generator.Color("red");
            // Specify the font size information for segment1
            seg1.TextInfo.FontSize = 12;
            // Specify the value for Opacity of text. Default is 1.0. Use it for multilayer effect
            t1.Opacity = 0F;
            // Add the segment to segments collection of Text1
            t1.Segments.Add(seg1);

            // JPeg image cover the underlayer text
            Aspose.Pdf.Generator.Image image1 = new Aspose.Pdf.Generator.Image(sec1);
            image1.ImageInfo.File = dataDir + "aspose-logo.jpg";
            image1.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Jpeg;

            // Create a Floating Box object that will hold image file
            Aspose.Pdf.Generator.FloatingBox ImageFloatingBox = new Aspose.Pdf.Generator.FloatingBox(117, 21);
            // Add Floating box to paragraphs collection of Section1
            sec1.Paragraphs.Add(ImageFloatingBox);

            // Specify the left margin of FloatingBox1
            ImageFloatingBox.Left = -4;
            // Specify the Top margin of FloatingBox1
            ImageFloatingBox.Top = -4;
            // Specify the ZIndex of ImageFloatingBox
            ImageFloatingBox.ZIndex = 2;
            // Add the image file to paragraphs collection of FloatingBox
            ImageFloatingBox.Paragraphs.Add(image1);

            // Save the reusltant PDF document
            pdf.Save(dataDir + @"Multilayer-2ndApproach_out.pdf");
            // ExEnd:SecondApproach
        }
        public static void Run()
        {
            try
            {
                // ExStart:InlineRadioButton
                // The path to the documents directory.
                string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Text();

                // Create Pdf Instance
                Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();

                // Add A Section
                Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();

                // Add Text Paragraph
                Aspose.Pdf.Generator.Text text1 = new Aspose.Pdf.Generator.Text();
                // Add Text Paragraph to paragraphs collection of section
                sec1.Paragraphs.Add(text1);
                // Add a segment with sample text to segments collection of Text Paragraph
                text1.Segments.Add("This is a test for inline radiobutton:    ");

                // Specify Inline Radio button field name
                text1.InlineRadioButtonFieldName = "inlineradio";
                // Specify the checked index for inline radio button
                text1.InlineRadioButtonCheckedIndex = 1;

                // Add segments
                Aspose.Pdf.Generator.Segment seg1 = text1.Segments.Add();

                // 1st Radio Button and set the Inline Paragraph property of segment equal to radioButton  
                Aspose.Pdf.Generator.RadioButton radio1 = new Aspose.Pdf.Generator.RadioButton();
                seg1.InlineParagraph = radio1;

                Aspose.Pdf.Generator.Segment seg11 = text1.Segments.Add("radio1  ");
                Aspose.Pdf.Generator.Segment seg2 = text1.Segments.Add();

                Aspose.Pdf.Generator.RadioButton radio2 = new Aspose.Pdf.Generator.RadioButton();
                radio2.ID = "radio2";
                seg2.InlineParagraph = radio2;

                Aspose.Pdf.Generator.Segment seg22 = text1.Segments.Add("radio2  ");
                Aspose.Pdf.Generator.Segment seg3 = text1.Segments.Add();
                Aspose.Pdf.Generator.RadioButton radio3 = new Aspose.Pdf.Generator.RadioButton();
                seg3.InlineParagraph = radio3;

                Aspose.Pdf.Generator.Segment seg33 = text1.Segments.Add("radio3  ");
                
                // Save the document
                pdf1.Save(dataDir + "InlineRadioButton_out.pdf");
                // ExEnd:InlineRadioButton
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
예제 #45
0
        public static void Run()
        {
            try
            {
                // ExStart:InlineRadioButton
                // The path to the documents directory.
                string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Text();

                // Create Pdf Instance
                Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();

                // Add A Section
                Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();

                // Add Text Paragraph
                Aspose.Pdf.Generator.Text text1 = new Aspose.Pdf.Generator.Text();
                // Add Text Paragraph to paragraphs collection of section
                sec1.Paragraphs.Add(text1);
                // Add a segment with sample text to segments collection of Text Paragraph
                text1.Segments.Add("This is a test for inline radiobutton:    ");

                // Specify Inline Radio button field name
                text1.InlineRadioButtonFieldName = "inlineradio";
                // Specify the checked index for inline radio button
                text1.InlineRadioButtonCheckedIndex = 1;

                // Add segments
                Aspose.Pdf.Generator.Segment seg1 = text1.Segments.Add();

                // 1st Radio Button and set the Inline Paragraph property of segment equal to radioButton
                Aspose.Pdf.Generator.RadioButton radio1 = new Aspose.Pdf.Generator.RadioButton();
                seg1.InlineParagraph = radio1;

                Aspose.Pdf.Generator.Segment seg11 = text1.Segments.Add("radio1  ");
                Aspose.Pdf.Generator.Segment seg2  = text1.Segments.Add();

                Aspose.Pdf.Generator.RadioButton radio2 = new Aspose.Pdf.Generator.RadioButton();
                radio2.ID            = "radio2";
                seg2.InlineParagraph = radio2;

                Aspose.Pdf.Generator.Segment     seg22  = text1.Segments.Add("radio2  ");
                Aspose.Pdf.Generator.Segment     seg3   = text1.Segments.Add();
                Aspose.Pdf.Generator.RadioButton radio3 = new Aspose.Pdf.Generator.RadioButton();
                seg3.InlineParagraph = radio3;

                Aspose.Pdf.Generator.Segment seg33 = text1.Segments.Add("radio3  ");

                // Save the document
                pdf1.Save(dataDir + "InlineRadioButton_out.pdf");
                // ExEnd:InlineRadioButton
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
예제 #46
0
        public static void Run()
        {
            // ExStart:RTLLanguages
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Text();

            // Instantiate Pdf instance by calling it empty constructor
            Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();
            // Create a section in the Pdf object
            pdf.Sections.Add();

            pdf.IsTruetypeFontMapCached = true;
            // Specify the location where to save TruetypeFontMap.xml
            pdf.TruetypeFontMapPath = dataDir + "";

            // Create a text object and pass the string object carrying arabic text in it
            Aspose.Pdf.Generator.Text text1 = new Aspose.Pdf.Generator.Text();
            // Create a segment and add it to segments collection of text object
            Aspose.Pdf.Generator.Segment seg0 = text1.Segments.Add();
            // Specify contents for segment
            seg0.Content = "أسبوز هو بائع عنصر ال";
            Aspose.Pdf.Generator.Segment seg1 = text1.Segments.Add();
            seg1.Content = ".NET";
            Aspose.Pdf.Generator.Segment seg2 = text1.Segments.Add();
            seg2.Content = "البارز";

            // Enable text alignment from right to left
            seg0.TextInfo.IsRightToLeft = true;
            seg1.TextInfo.IsRightToLeft = false;         //default
            seg2.TextInfo.IsRightToLeft = true;

            // Enable unicode character set for the text segment
            seg0.TextInfo.IsUnicode = true;
            seg1.TextInfo.IsUnicode = true;
            seg2.TextInfo.IsUnicode = true;

            // Set Font Name
            seg0.TextInfo.FontName = "Times New Roman";
            seg1.TextInfo.FontName = "Times New Roman";
            seg2.TextInfo.FontName = "Times New Roman";
            // Set font size
            seg0.TextInfo.FontSize = 14;
            seg1.TextInfo.FontSize = 14;
            seg2.TextInfo.FontSize = 14;

            // Align text to right hand side using AlignmentType enumeration
            // Make the text right aligned(The meaning of Alignment.Left and AlignmentType.Right are //exchanged when processing RTL language).
            text1.TextInfo.Alignment = Aspose.Pdf.Generator.AlignmentType.Left;

            pdf.Sections[0].Paragraphs.Add(text1);
            pdf.IsRtlInSegmentMode = true;         //default

            pdf.Save(dataDir + "RTLLanguages_out_.pdf");
            // ExEnd:RTLLanguages
        }
        public static void UsingInlineParagraph()
        {
            // ExStart:UsingInlineParagraph
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_TechnicalArticles();

            // Instantiate a Pdf object by calling its empty constructor
            Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
            // Create a section in the Pdf object
            Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();

            //=====================================================//
            //	Header to show an Image inline with text
            //=====================================================//

            // Create Header Section of the document
            Aspose.Pdf.Generator.HeaderFooter header = new Aspose.Pdf.Generator.HeaderFooter(sec1);
            // Set the Odd header for the PDF file
            sec1.OddHeader = header;
            // Set the Even Header for the PDF file
            sec1.EvenHeader = header;

            // Create a Text object
            Aspose.Pdf.Generator.Text txt1 = new Aspose.Pdf.Generator.Text();
            // Add text to Header section of the Pdf file
            header.Paragraphs.Add(txt1);

            // Add the text string to Segment of text object
            txt1.Segments.Add("Aspose.Pdf is a Robust component by");
            // Specify the color & Font information using TextInfo property
            txt1.TextInfo.Color = new Aspose.Pdf.Generator.Color("Blue");
            txt1.TextInfo.FontName = "Helvetica";
            // Create a new segment to be added to text object
            Aspose.Pdf.Generator.Segment seg1 = txt1.Segments.Add();

            // Create an image object in the section
            Aspose.Pdf.Generator.Image image1 = new Aspose.Pdf.Generator.Image(sec1);
            // Set the path of image file
            image1.ImageInfo.File = dataDir + "aspose-logo.jpg";
            // Set the type of image using ImageFileType enumeration
            image1.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Jpeg;
            // Set the image width Information
            image1.ImageInfo.FixWidth = 150;
            // Indicate seg1's InlineParagraph is a image.
            seg1.InlineParagraph = image1;

            // Create a new segment to be added to text object
            Aspose.Pdf.Generator.Segment seg2 = txt1.Segments.Add("Pty Ltd.");
            seg2.TextInfo.Color = new Aspose.Pdf.Generator.Color("Maroon");

            // Save the Pdf
            pdf1.Save( dataDir + "ImageAndPageNumberInHeaderFooter_UsingInlineParagraph_out.pdf");
            // ExEnd:UsingInlineParagraph
        }
        public static void UsingInlineParagraph()
        {
            // ExStart:UsingInlineParagraph
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_TechnicalArticles();

            // Instantiate a Pdf object by calling its empty constructor
            Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
            // Create a section in the Pdf object
            Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();

            //=====================================================//
            //	Header to show an Image inline with text
            //=====================================================//

            // Create Header Section of the document
            Aspose.Pdf.Generator.HeaderFooter header = new Aspose.Pdf.Generator.HeaderFooter(sec1);
            // Set the Odd header for the PDF file
            sec1.OddHeader = header;
            // Set the Even Header for the PDF file
            sec1.EvenHeader = header;

            // Create a Text object
            Aspose.Pdf.Generator.Text txt1 = new Aspose.Pdf.Generator.Text();
            // Add text to Header section of the Pdf file
            header.Paragraphs.Add(txt1);

            // Add the text string to Segment of text object
            txt1.Segments.Add("Aspose.Pdf is a Robust component by");
            // Specify the color & Font information using TextInfo property
            txt1.TextInfo.Color    = new Aspose.Pdf.Generator.Color("Blue");
            txt1.TextInfo.FontName = "Helvetica";
            // Create a new segment to be added to text object
            Aspose.Pdf.Generator.Segment seg1 = txt1.Segments.Add();

            // Create an image object in the section
            Aspose.Pdf.Generator.Image image1 = new Aspose.Pdf.Generator.Image(sec1);
            // Set the path of image file
            image1.ImageInfo.File = dataDir + "aspose-logo.jpg";
            // Set the type of image using ImageFileType enumeration
            image1.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Jpeg;
            // Set the image width Information
            image1.ImageInfo.FixWidth = 150;
            // Indicate seg1's InlineParagraph is a image.
            seg1.InlineParagraph = image1;

            // Create a new segment to be added to text object
            Aspose.Pdf.Generator.Segment seg2 = txt1.Segments.Add("Pty Ltd.");
            seg2.TextInfo.Color = new Aspose.Pdf.Generator.Color("Maroon");

            // Save the Pdf
            pdf1.Save(dataDir + "ImageAndPageNumberInHeaderFooter_UsingInlineParagraph_out.pdf");
            // ExEnd:UsingInlineParagraph
        }
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Text();

            // Create directory if it is not already present.
            bool IsExists = System.IO.Directory.Exists(dataDir);

            if (!IsExists)
            {
                System.IO.Directory.CreateDirectory(dataDir);
            }

            //Instantiate Pdf instance by calling its empty constructor
            Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();

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

//Create 1st text paragraph
            Aspose.Pdf.Generator.Text text1 = new Aspose.Pdf.Generator.Text(sec1, "FillText mode");

//Set rendering mode to FillText
            text1.TextInfo.RenderingMode = Aspose.Pdf.Generator.RenderingMode.FillText;

//Create 2nd text paragraph
            Aspose.Pdf.Generator.Text text2 = new Aspose.Pdf.Generator.Text(sec1, "StrokeText mode (outline)");

//Set rendering mode to StrokeText
            text2.TextInfo.RenderingMode = Aspose.Pdf.Generator.RenderingMode.StrokeText;

//Create 3rd text paragraph
            Aspose.Pdf.Generator.Text text3 = new Aspose.Pdf.Generator.Text(sec1, "FillStrokeText mode");

//Set rendering mode to FillStrokeText
            text3.TextInfo.RenderingMode = Aspose.Pdf.Generator.RenderingMode.FillStrokeText;

//Create 4th text paragraph
            Aspose.Pdf.Generator.Text text4 = new Aspose.Pdf.Generator.Text(sec1, "InvisibleText mode");

//Set rendering mode to InvisibleText
            text4.TextInfo.RenderingMode = Aspose.Pdf.Generator.RenderingMode.InvisibleText;

//Add 1st, 2nd, 3rd and 4th text paragraphs to the section
            sec1.Paragraphs.Add(text1);
            sec1.Paragraphs.Add(text2);
            sec1.Paragraphs.Add(text3);
            sec1.Paragraphs.Add(text4);

//Save the Pdf
            pdf1.Save(dataDir + "Output.pdf");
        }
        public static void ParagraphsCustomPositioning()
        {
            // ExStart:ParagraphsCustomPositioning
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_UtilityFeatures();

            // Instantiate the Pdf object
            Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();

            // Add a section to the Pdf object
            Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();

            // Create a text paragraph
            Aspose.Pdf.Generator.Text text1 = new Aspose.Pdf.Generator.Text("This is a text paragraph.");

            // Set the id of the paragraph to "text1" so that it can referenced uniquely
            text1.ID = "text1";

            // Add the paragraph to the section
            sec1.Paragraphs.Add(text1);

            // Create a graph with specified left and top position settings. Set its
            // Poition relative to the page. Add a rectangle to its shapes collection and
            // Then add the graph to the paragraph collection of the section
            Aspose.Pdf.Generator.Graph graph1 = new Aspose.Pdf.Generator.Graph(200, 50);
            graph1.Left = 200;
            graph1.Top = 10;
            graph1.PositioningType = Aspose.Pdf.Generator.PositioningType.PageRelative;
            graph1.Shapes.Add(new Aspose.Pdf.Generator.Rectangle(0, 0, 200, 50));
            sec1.Paragraphs.Add(graph1);

            // Create an attachment as note annotation and add it to the section as a
            // Pragraph. Set the content and heading for the note. Set its position relative
            // To the paragraph. Assign a unique id to this note annotation for the
            // Reference purposes and then customize its left and top position
            Aspose.Pdf.Generator.Attachment noteAttachment = new Aspose.Pdf.Generator.Attachment();
            sec1.Paragraphs.Add(noteAttachment);
            noteAttachment.AttachmentType = Aspose.Pdf.Generator.AttachmentType.Note;
            noteAttachment.NoteContent = "This is a test for note";
            noteAttachment.NoteHeading = "this is a Note";
            noteAttachment.PositioningType = Aspose.Pdf.Generator.PositioningType.ParagraphRelative;
            noteAttachment.ReferenceParagraphID = "text1";
            noteAttachment.Left = 200;
            noteAttachment.Top = 0; 

            dataDir = dataDir + "ParagraphsCustomPositioning_out.pdf";
            // Save the Pdf
            pdf1.Save(dataDir);
            // ExEnd:ParagraphsCustomPositioning           
        }
예제 #51
0
        public static void ParagraphsCustomPositioning()
        {
            // ExStart:ParagraphsCustomPositioning
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_UtilityFeatures();

            // Instantiate the Pdf object
            Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();

            // Add a section to the Pdf object
            Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();

            // Create a text paragraph
            Aspose.Pdf.Generator.Text text1 = new Aspose.Pdf.Generator.Text("This is a text paragraph.");

            // Set the id of the paragraph to "text1" so that it can referenced uniquely
            text1.ID = "text1";

            // Add the paragraph to the section
            sec1.Paragraphs.Add(text1);

            // Create a graph with specified left and top position settings. Set its
            // poition relative to the page. Add a rectangle to its shapes collection and
            // then add the graph to the paragraph collection of the section
            Aspose.Pdf.Generator.Graph graph1 = new Aspose.Pdf.Generator.Graph(200, 50);
            graph1.Left            = 200;
            graph1.Top             = 10;
            graph1.PositioningType = Aspose.Pdf.Generator.PositioningType.PageRelative;
            graph1.Shapes.Add(new Aspose.Pdf.Generator.Rectangle(0, 0, 200, 50));
            sec1.Paragraphs.Add(graph1);

            // Create an attachment as note annotation and add it to the section as a
            // pragraph. Set the content and heading for the note. Set its position relative
            // to the paragraph. Assign a unique id to this note annotation for the
            // reference purposes and then customize its left and top position
            Aspose.Pdf.Generator.Attachment noteAttachment = new Aspose.Pdf.Generator.Attachment();
            sec1.Paragraphs.Add(noteAttachment);
            noteAttachment.AttachmentType       = Aspose.Pdf.Generator.AttachmentType.Note;
            noteAttachment.NoteContent          = "This is a test for note";
            noteAttachment.NoteHeading          = "this is a Note";
            noteAttachment.PositioningType      = Aspose.Pdf.Generator.PositioningType.ParagraphRelative;
            noteAttachment.ReferenceParagraphID = "text1";
            noteAttachment.Left = 200;
            noteAttachment.Top  = 0;

            dataDir = dataDir + "ParagraphsCustomPositioning_out_.pdf";
            // Save the Pdf
            pdf1.Save(dataDir);
            // ExEnd:ParagraphsCustomPositioning
        }
예제 #52
0
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Text();

             // Create directory if it is not already present.
            bool IsExists = System.IO.Directory.Exists(dataDir);
            if (!IsExists)
                System.IO.Directory.CreateDirectory(dataDir);

            //Instantiate Pdf instance by calling its empty constructor
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();

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

//Create 1st text paragraph
Aspose.Pdf.Generator.Text text1 = new Aspose.Pdf.Generator.Text(sec1,"FillText mode");

//Set rendering mode to FillText
text1.TextInfo.RenderingMode= Aspose.Pdf.Generator.RenderingMode.FillText;

//Create 2nd text paragraph
Aspose.Pdf.Generator.Text text2 = new Aspose.Pdf.Generator.Text(sec1,"StrokeText mode (outline)");

//Set rendering mode to StrokeText
text2.TextInfo.RenderingMode= Aspose.Pdf.Generator.RenderingMode.StrokeText;

//Create 3rd text paragraph
Aspose.Pdf.Generator.Text text3 = new Aspose.Pdf.Generator.Text(sec1,"FillStrokeText mode");

//Set rendering mode to FillStrokeText
text3.TextInfo.RenderingMode= Aspose.Pdf.Generator.RenderingMode.FillStrokeText;

//Create 4th text paragraph
Aspose.Pdf.Generator.Text text4 = new Aspose.Pdf.Generator.Text(sec1,"InvisibleText mode");

//Set rendering mode to InvisibleText
text4.TextInfo.RenderingMode= Aspose.Pdf.Generator.RenderingMode.InvisibleText;

//Add 1st, 2nd, 3rd and 4th text paragraphs to the section
sec1.Paragraphs.Add(text1);
sec1.Paragraphs.Add(text2);
sec1.Paragraphs.Add(text3);
sec1.Paragraphs.Add(text4);

//Save the Pdf
pdf1.Save(dataDir+ "Output.pdf");
 
        }
예제 #53
0
        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:ImageAndPageNumberInHeaderFooter
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_TechnicalArticles();

            // Instantiate a Pdf object by calling its empty constructor
            Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
            // Create a section in the Pdf object
            Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();

            //=====================================================//
            //	Header to show an Image
            //=====================================================//

            // Create Header Section of the document
            Aspose.Pdf.Generator.HeaderFooter header = new Aspose.Pdf.Generator.HeaderFooter(sec1);
            // Set the Odd header for the PDF file
            sec1.OddHeader = header;
            // Set the Even Header for the PDF file
            sec1.EvenHeader = header;
            // Create an image object in the section
            Aspose.Pdf.Generator.Image image1 = new Aspose.Pdf.Generator.Image(sec1);
            // Set the path of image file
            image1.ImageInfo.File = dataDir + "aspose-logo.jpg";
            // Set the type of image using ImageFileType enumeration
            image1.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Jpeg;
            // Add image to Header section of the Pdf file
            header.Paragraphs.Add(image1);

            //=====================================================//
            //	Footer to show Page Number
            //=====================================================//

            // Create a Footer Section of the document
            Aspose.Pdf.Generator.HeaderFooter footer = new Aspose.Pdf.Generator.HeaderFooter(sec1);
            // Set the Odd footer of the PDF file
            sec1.OddFooter = footer;
            // Set the Even footer of the PDF file
            sec1.EvenFooter = footer;
            // Create a Text object
            Aspose.Pdf.Generator.Text txt = new Aspose.Pdf.Generator.Text("Page: ($p of $P ) ");
            // Add text to Header section of the Pdf file
            footer.Paragraphs.Add(txt);
            // Save the Pdf file
            pdf1.Save(dataDir + "ImageAndPageNumberInHeaderFooter_out.pdf");
            // ExEnd:ImageAndPageNumberInHeaderFooter
        }
        public static void Run()
        {
            // ExStart:ImageAndPageNumberInHeaderFooter
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_TechnicalArticles();

            // Instantiate a Pdf object by calling its empty constructor
            Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
            // Create a section in the Pdf object
            Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();

            //=====================================================//
            //	Header to show an Image
            //=====================================================//

            // Create Header Section of the document
            Aspose.Pdf.Generator.HeaderFooter header = new Aspose.Pdf.Generator.HeaderFooter(sec1);
            // Set the Odd header for the PDF file
            sec1.OddHeader = header;
            // Set the Even Header for the PDF file
            sec1.EvenHeader = header;
            // Create an image object in the section
            Aspose.Pdf.Generator.Image image1 = new Aspose.Pdf.Generator.Image(sec1);
            // Set the path of image file
            image1.ImageInfo.File = dataDir + "aspose-logo.jpg";
            // Set the type of image using ImageFileType enumeration
            image1.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Jpeg;
            // Add image to Header section of the Pdf file
            header.Paragraphs.Add(image1);

            //=====================================================//
            //	Footer to show Page Number
            //=====================================================//

            // Create a Footer Section of the document
            Aspose.Pdf.Generator.HeaderFooter footer = new Aspose.Pdf.Generator.HeaderFooter(sec1);
            // Set the Odd footer of the PDF file
            sec1.OddFooter = footer;
            // Set the Even footer of the PDF file
            sec1.EvenFooter = footer;
            // Create a Text object
            Aspose.Pdf.Generator.Text txt = new Aspose.Pdf.Generator.Text("Page: ($p of $P ) ");
            // Add text to Header section of the Pdf file
            footer.Paragraphs.Add(txt);
            // Save the Pdf file
            pdf1.Save(dataDir + "ImageAndPageNumberInHeaderFooter_out.pdf");
            // ExEnd:ImageAndPageNumberInHeaderFooter           
        }
예제 #56
0
        public static void Main(string[] args)
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");

            //Instantiate a Pdf object by calling its empty constructor
            Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
            //Create a section in the Pdf object
            Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();

            //=====================================================//
            //	Header to show an Image
            //=====================================================//

            // Create Header Section of the document
            Aspose.Pdf.Generator.HeaderFooter header = new Aspose.Pdf.Generator.HeaderFooter(sec1);
            // set the Odd header for the PDF file
            sec1.OddHeader = header;
            // Set the Even Header for the PDF file
            sec1.EvenHeader = header;
            //Create an image object in the section
            Aspose.Pdf.Generator.Image image1 = new Aspose.Pdf.Generator.Image(sec1);
            //Set the path of image file
            image1.ImageInfo.File = dataDir + "aspose.jpg";
            //Set the type of image using ImageFileType enumeration
            image1.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Jpeg;
            //Add image to Header section of the Pdf file
            header.Paragraphs.Add(image1);

            //=====================================================//
            //	Footer to show Page Number
            //=====================================================//

            // Create a Footer Section of the document
            Aspose.Pdf.Generator.HeaderFooter footer = new Aspose.Pdf.Generator.HeaderFooter(sec1);
            // set the Odd footer of the PDF file
            sec1.OddFooter = footer;
            // set the Even footer of the PDF file
            sec1.EvenFooter = footer;
            // Create a Text object
            Aspose.Pdf.Generator.Text txt = new Aspose.Pdf.Generator.Text("Page: ($p of $P ) ");
            // Add text to Header section of the Pdf file
            footer.Paragraphs.Add(txt);

            //Save the Pdf
            pdf1.Save(dataDir + "pdfWithHeaderAndPageNos.pdf");
        }
예제 #57
0
        public static void Main(string[] args)
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");

            //Instantiate a Pdf object by calling its empty constructor
            Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
            //Create a section in the Pdf object
            Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();

            //=====================================================//
            //	Header to show an Image
            //=====================================================//

            // Create Header Section of the document
            Aspose.Pdf.Generator.HeaderFooter header = new Aspose.Pdf.Generator.HeaderFooter(sec1);
            // set the Odd header for the PDF file
            sec1.OddHeader = header;
            // Set the Even Header for the PDF file
            sec1.EvenHeader = header;
            //Create an image object in the section
            Aspose.Pdf.Generator.Image image1 = new Aspose.Pdf.Generator.Image(sec1);
            //Set the path of image file
            image1.ImageInfo.File = dataDir + "aspose.jpg";
            //Set the type of image using ImageFileType enumeration
            image1.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Jpeg;
            //Add image to Header section of the Pdf file
            header.Paragraphs.Add(image1);

            //=====================================================//
            //	Footer to show Page Number
            //=====================================================//

            // Create a Footer Section of the document
            Aspose.Pdf.Generator.HeaderFooter footer = new Aspose.Pdf.Generator.HeaderFooter(sec1);
            // set the Odd footer of the PDF file
            sec1.OddFooter = footer;
            // set the Even footer of the PDF file
            sec1.EvenFooter = footer;
            // Create a Text object
            Aspose.Pdf.Generator.Text txt = new Aspose.Pdf.Generator.Text("Page: ($p of $P ) ");
            // Add text to Header section of the Pdf file
            footer.Paragraphs.Add(txt);

            //Save the Pdf
            pdf1.Save(dataDir + "pdfWithHeaderAndPageNos.pdf");
        }
예제 #58
0
        public static void Run()
        {
            // ExStart:SetRenderingMode
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Text();

            // Instantiate Pdf instance by calling its empty constructor
            Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();

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

            // Create 1st text paragraph
            Aspose.Pdf.Generator.Text text1 = new Aspose.Pdf.Generator.Text(sec1, "FillText mode");

            // Set rendering mode to FillText
            text1.TextInfo.RenderingMode = Aspose.Pdf.Generator.RenderingMode.FillText;

            // Create 2nd text paragraph
            Aspose.Pdf.Generator.Text text2 = new Aspose.Pdf.Generator.Text(sec1, "StrokeText mode (outline)");

            // Set rendering mode to StrokeText
            text2.TextInfo.RenderingMode = Aspose.Pdf.Generator.RenderingMode.StrokeText;

            // Create 3rd text paragraph
            Aspose.Pdf.Generator.Text text3 = new Aspose.Pdf.Generator.Text(sec1, "FillStrokeText mode");

            // Set rendering mode to FillStrokeText
            text3.TextInfo.RenderingMode = Aspose.Pdf.Generator.RenderingMode.FillStrokeText;

            // Create 4th text paragraph
            Aspose.Pdf.Generator.Text text4 = new Aspose.Pdf.Generator.Text(sec1, "InvisibleText mode");

            // Set rendering mode to InvisibleText
            text4.TextInfo.RenderingMode = Aspose.Pdf.Generator.RenderingMode.InvisibleText;

            // Add 1st, 2nd, 3rd and 4th text paragraphs to the section
            sec1.Paragraphs.Add(text1);
            sec1.Paragraphs.Add(text2);
            sec1.Paragraphs.Add(text3);
            sec1.Paragraphs.Add(text4);

            // Save the Pdf
            pdf1.Save(dataDir + "SetRenderingMode_out.pdf");
            // ExEnd:SetRenderingMode
        }