public static void Run()
        {
            try
            {
                // ExStart:HelloWorldUsingAPI
                // The path to the documents directory.
                string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_General();

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

                // Instantiate License class and call its SetLicense method to use the license
                Aspose.Pdf.License license = new Aspose.Pdf.License();
                license.SetLicense("Aspose.Pdf.lic");

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

                // Add a text paragraph into the section
                sec1.Paragraphs.Add(new Aspose.Pdf.Generator.Text("Hello World"));

                dataDir = dataDir + "HelloWorldUsingAPI_out.pdf";
                // Save the document
                pdf1.Save(dataDir);
                // ExEnd:HelloWorldUsingAPI
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message + "\nThis example will only work if you apply a valid Aspose License. You can purchase full license or get 30 day temporary license from http:// Www.aspose.com/purchase/default.aspx.");
            }
        }
Ejemplo n.º 2
0
        public static void Run()
        {
            try
            {
                // ExStart:HelloWorldUsingXSLT
                // The path to the documents directory.
                string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_General();

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

                // Instantiate License class and call its SetLicense method to use the license
                Aspose.Pdf.License license = new Aspose.Pdf.License();
                license.SetLicense("Aspose.Pdf.lic");

                // Bind XML and XSLT files to the document
                pdf1.BindXML(dataDir + "HelloWorldUsingXSLT.XML", dataDir + "HelloWorld.xslt");

                dataDir = dataDir + "HelloWorldUsingXSLT_out_.pdf";
                // Save the document
                pdf1.Save(dataDir);
                // ExEnd:HelloWorldUsingXSLT
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message + "\nThis example will only work if you apply a valid Aspose License. You can purchase full license or get 30 day temporary license from http:// Www.aspose.com/purchase/default.aspx.");
            }
        }
Ejemplo n.º 3
0
        public static void Run()
        {
            try
            {
                // ExStart:ImageFromMemory
                // The path to the documents directory.
                string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_General();

                // Set the license for Aspose.Pdf
                Aspose.Pdf.License license = new Aspose.Pdf.License();
                license.SetLicense("Aspose.Custom.lic");

                // Create a memory stream object
                System.IO.MemoryStream mstream = new System.IO.MemoryStream();

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

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

                // Add the section in the sections collection of the Pdf document
                pdf1.Sections.Add(sec1);

                // Create an image object
                Aspose.Pdf.Generator.Image image1 = new Aspose.Pdf.Generator.Image(sec1);

                // Add the image into paragraphs collection of the section
                sec1.Paragraphs.Add(image1);

                image1.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Bmp;

                // Set the ImageStream to a MemoryStream object
                image1.ImageInfo.ImageStream = mstream;

                // Set desired the image scale
                image1.ImageScale = 0.5F;

                // Save the Pdf
                pdf1.Save(dataDir + "ImageFromMemory_out.pdf");
                // ExEnd:ImageFromMemory
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message + "\nThis example will only work if you apply a valid Aspose License. You can purchase full license or get 30 day temporary license from http:// Www.aspose.com/purchase/default.aspx.");
            }
        }
        public static void Run()
        {
            try
            {
                // ExStart:PositionFloatingBox
                // The path to the documents directory.
                string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_General();

                // 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 FloatingBox with 108 as width and 80 as height
                Aspose.Pdf.Generator.FloatingBox box1 = new Aspose.Pdf.Generator.FloatingBox(108, 80);
                // add FloatingBox to paragraphs collection of section object
                sec1.Paragraphs.Add(box1);
                // ExStart:PositionFloatingBox-1
                // Specify the Horizontal Positioning type for FloatingBox as Margin
                box1.BoxHorizontalPositioning = Aspose.Pdf.Generator.BoxHorizontalPositioningType.Margin;
                // Set the left margin information as 200
                box1.Left = 200;
                // Specify the Vertical Positioning type for FloatingBox object
                box1.BoxVerticalPositioning = Aspose.Pdf.Generator.BoxVerticalPositioningType.Page;
                // Set the Top margin information as 300
                box1.Top = 300;
                // ExEnd:PositionFloatingBox-1
                // Add sample text string to paragraphs collection of FloatingBox object
                box1.Paragraphs.Add(new Aspose.Pdf.Generator.Text("Hello."));

                dataDir = dataDir + "PositionFloatingBox_out_.pdf";
                // Save the resultant PDF
                pdf1.Save(dataDir);
                // ExEnd:PositionFloatingBox
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message + "\nThis example will only work if you apply a valid Aspose License. You can purchase full license or get 30 day temporary license from http:// Www.aspose.com/purchase/default.aspx.");
            }
        }
        public static void Run()
        {
            try
            {
                // ExStart:HelloWorldUsingXMLAndAPI
                // The path to the documents directory.
                string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_General();

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

                // Instantiate License class and call its SetLicense method to use the license
                Aspose.Pdf.License license = new Aspose.Pdf.License();
                license.SetLicense("Aspose.Pdf.lic");

                // Bind XML into the document
                pdf1.BindXML(dataDir + "HelloWorldUsingAPI.XML", null);

                // Get the first Section from the PDF document
                Aspose.Pdf.Generator.Section sec1 = pdf1.Sections[0];

                // Get the Text paragraph (whose ID is Text1) from the section
                Aspose.Pdf.Generator.Text text1 = sec1.Paragraphs["Text1"] as Aspose.Pdf.Generator.Text;

                // Add a text Segment to the text paragraph
                text1.Segments.Add("Hello World");

                dataDir = dataDir + "HelloWorldUsingXMLAndAPI_out_.pdf";
                // Save the document
                pdf1.Save(dataDir);
                // ExEnd:HelloWorldUsingXMLAndAPI
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message + "\nThis example will only work if you apply a valid Aspose License. You can purchase full license or get 30 day temporary license from http:// Www.aspose.com/purchase/default.aspx.");
            }
        }