Exemplo n.º 1
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);
        }
Exemplo n.º 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");
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
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 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");
        }
Exemplo n.º 5
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();

            //Instantiate a graph object, associate it with a section and pass the height
            // & width of the graph
            Aspose.Pdf.Generator.Graph g1 = new Aspose.Pdf.Generator.Graph(sec1, 100, 100);

            //Add a graph object to the paragraphs collection of the section
            sec1.Paragraphs.Add(g1);

            //Add a circle object to the shapes collection of graph object
            g1.Shapes.Add(new Aspose.Pdf.Generator.Circle(g1, 50, 50, 30));

            //Instantiate another Graph object, associate it with a section and pass the height
            // & width of the graph
            Aspose.Pdf.Generator.Graph g2 = new Aspose.Pdf.Generator.Graph(sec1, 100, 100);

            //Set the value of left margin
            g2.Margin.Left = 150;

            //Set the value of top margin and assign a negative value to it
            g2.Margin.Top = -100;

            //Add the paragraph object "g2" to paragraphs collection of the section
            sec1.Paragraphs.Add(g2);

            //Add a rectangle to the graph object (g2) in its shapes collection
            g2.Shapes.Add(new Aspose.Pdf.Generator.Rectangle(g2, 20, 20, 60, 60));

            // save the resultant PDF
            pdf1.Save(dataDir + "MergedOutput.pdf");
        }
Exemplo n.º 6
0
        public static void Run()
        {
            // ExStart:SetMargins
            // 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();

            // Instantiate a graph object, associate it with a section and pass the height & width of the graph
            Aspose.Pdf.Generator.Graph g1 = new Aspose.Pdf.Generator.Graph(sec1, 100, 100);

            // Add a graph object to the paragraphs collection of the section
            sec1.Paragraphs.Add(g1);

            // Add a circle object to the shapes collection of graph object
            g1.Shapes.Add(new Aspose.Pdf.Generator.Circle(g1, 50, 50, 30));

            // Instantiate another Graph object, associate it with a section and pass the height & width of the graph
            Aspose.Pdf.Generator.Graph g2 = new Aspose.Pdf.Generator.Graph(sec1, 100, 100);

            // Set left and top margin values
            g2.Margin.Left = 150;
            g2.Margin.Top  = -100;

            // Add the paragraph object "g2" to paragraphs collection of the section
            sec1.Paragraphs.Add(g2);

            // Add a rectangle to the graph object (g2) in its shapes collection
            g2.Shapes.Add(new Aspose.Pdf.Generator.Rectangle(g2, 20, 20, 60, 60));

            dataDir = dataDir + "SetMargins_out_.pdf";
            // Save the resultant PDF
            pdf1.Save(dataDir);
            // ExEnd:SetMargins
            Console.WriteLine("\nParagraph margins setup successfully.\nFile saved at " + dataDir);
        }