コード例 #1
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);
        }
コード例 #2
0
        public static void Run()
        {
            // ExStart:ReplaceableSymbols
            // 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();

            // Create a HeaderFooter object for the section
            Aspose.Pdf.Generator.HeaderFooter hf = new Aspose.Pdf.Generator.HeaderFooter(sec1);

            // Set the HeaderFooter object to odd and even footers
            sec1.OddFooter = sec1.EvenFooter = hf;

            // Add a text paragraph containing current page number of total number of pages
            hf.Paragraphs.Add(new Aspose.Pdf.Generator.Text(hf, "page $p of $P"));

            dataDir = dataDir + "ReplaceableSymbols_out.pdf";
            // Create the result PDF Document
            pdf1.Save(dataDir);
            // ExEnd:ReplaceableSymbols
        }
コード例 #3
0
        public static void Run()
        {
            // ExStart:ReplaceableSymbols
            // 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();

            // Create a HeaderFooter object for the section
            Aspose.Pdf.Generator.HeaderFooter hf = new Aspose.Pdf.Generator.HeaderFooter(sec1);

            // Set the HeaderFooter object to odd and even footers
            sec1.OddFooter = sec1.EvenFooter = hf;

            // Add a text paragraph containing current page number of total number of pages
            hf.Paragraphs.Add(new Aspose.Pdf.Generator.Text(hf, "page $p of $P"));

            dataDir = dataDir + "ReplaceableSymbols_out.pdf";
            // Create the result PDF Document
            pdf1.Save(dataDir);
            // ExEnd:ReplaceableSymbols
        }
        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()
        {
            // 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
        }
コード例 #8
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");
        }
コード例 #9
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");
        }
コード例 #10
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);
        }
コード例 #11
0
        public static void Main(string[] args)
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");

            //Instantiate PDF instance by calling empty constructor
            Aspose.Pdf.Generator.Pdf pdfConv = new Aspose.Pdf.Generator.Pdf();
            //Create a section in the pdf document
            Aspose.Pdf.Generator.Section sec1 = pdfConv.Sections.Add();

            // Create a Header Section of the PDF file
            Aspose.Pdf.Generator.HeaderFooter header = new Aspose.Pdf.Generator.HeaderFooter(sec1);
            // Set the Odd Header for the PDF file
            sec1.OddHeader = header;
            // set the top margin for the header section
            header.Margin.Top = 20;

            //Instantiate a table object
            Aspose.Pdf.Generator.Table tab1 = new Aspose.Pdf.Generator.Table();
            //Add the table in paragraphs collection of the desired section
            header.Paragraphs.Add(tab1);
            //Set default cell border using BorderInfo object
            tab1.DefaultCellBorder = new Aspose.Pdf.Generator.BorderInfo((int)Aspose.Pdf.Generator.BorderSide.All, 0.1F);
            //Set with column widths of the table
            tab1.ColumnWidths = "60 300";

            Aspose.Pdf.Generator.Image img = new Aspose.Pdf.Generator.Image();
            img.ImageInfo.File          = dataDir + "asposelogo.png";
            img.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Png;

            //Create rows in the table and then cells in the rows
            Aspose.Pdf.Generator.Row row1 = tab1.Rows.Add();

            row1.Cells.Add("Table in Header Section");
            row1.BackgroundColor           = new Aspose.Pdf.Generator.Color("#CCCCCC");
            row1.DefaultCellTextInfo.Color = new Aspose.Pdf.Generator.Color("#6699FF");
            // set the font face for the text in the row
            row1.DefaultCellTextInfo.FontName = "Helvetica";
            // set the row span value for first row as 2
            tab1.Rows[0].Cells[0].ColumnsSpan = 2;

            //Create rows in the table and then cells in the rows
            Aspose.Pdf.Generator.Row row2 = tab1.Rows.Add();
            // set the background color for Row2
            row2.BackgroundColor = new Aspose.Pdf.Generator.Color("#FFFFCC");
            // Add the cell which holds the image
            Aspose.Pdf.Generator.Cell cell2 = row2.Cells.Add();
            // set the image width to 60
            img.ImageInfo.FixWidth = 60;

            Aspose.Pdf.Generator.Text txt2 = new Aspose.Pdf.Generator.Text();
            // Add a text segment to hold image and text together
            Aspose.Pdf.Generator.Segment seg1 = new Aspose.Pdf.Generator.Segment();
            seg1.InlineParagraph = img;
            txt2.Segments.Add(seg1);

            //Add the image to the table cell
            cell2.Paragraphs.Add(txt2);
            row2.Cells.Add("Aspose Logo is looking very lovely !");
            row2.DefaultCellTextInfo.FontName = "Helvetica";
            // set the vertical allignment of the text as center alligned
            row2.Cells[1].VerticalAlignment = Aspose.Pdf.Generator.VerticalAlignmentType.Center;
            row2.Cells[1].Alignment         = Aspose.Pdf.Generator.AlignmentType.Center;

            // save the Pdf file
            pdfConv.Save(dataDir + "Table_in_Header.pdf");
        }
コード例 #12
0
        public static void Main(string[] args)
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");

            //Instantiate PDF instance by calling empty constructor
            Aspose.Pdf.Generator.Pdf pdfConv = new Aspose.Pdf.Generator.Pdf();
            //Create a section in the pdf document
            Aspose.Pdf.Generator.Section sec1 = pdfConv.Sections.Add();

            // Create a Header Section of the PDF file
            Aspose.Pdf.Generator.HeaderFooter header = new Aspose.Pdf.Generator.HeaderFooter(sec1);
            // Set the Odd Header for the PDF file
            sec1.OddHeader = header;
            // set the top margin for the header section
            header.Margin.Top = 20;

            //Instantiate a table object
            Aspose.Pdf.Generator.Table tab1 = new Aspose.Pdf.Generator.Table();
            //Add the table in paragraphs collection of the desired section
            header.Paragraphs.Add(tab1);
            //Set default cell border using BorderInfo object
            tab1.DefaultCellBorder = new Aspose.Pdf.Generator.BorderInfo((int)Aspose.Pdf.Generator.BorderSide.All, 0.1F);
            //Set with column widths of the table
            tab1.ColumnWidths = "60 300";

            Aspose.Pdf.Generator.Image img = new Aspose.Pdf.Generator.Image();
            img.ImageInfo.File = dataDir + "asposelogo.png";
            img.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Png;

            //Create rows in the table and then cells in the rows
            Aspose.Pdf.Generator.Row row1 = tab1.Rows.Add();

            row1.Cells.Add("Table in Header Section");
            row1.BackgroundColor = new Aspose.Pdf.Generator.Color("#CCCCCC");
            row1.DefaultCellTextInfo.Color = new Aspose.Pdf.Generator.Color("#6699FF");
            // set the font face for the text in the row
            row1.DefaultCellTextInfo.FontName = "Helvetica";
            // set the row span value for first row as 2
            tab1.Rows[0].Cells[0].ColumnsSpan = 2;

            //Create rows in the table and then cells in the rows
            Aspose.Pdf.Generator.Row row2 = tab1.Rows.Add();
            // set the background color for Row2
            row2.BackgroundColor = new Aspose.Pdf.Generator.Color("#FFFFCC");
            // Add the cell which holds the image
            Aspose.Pdf.Generator.Cell cell2 = row2.Cells.Add();
            // set the image width to 60
            img.ImageInfo.FixWidth = 60;

            Aspose.Pdf.Generator.Text txt2 = new Aspose.Pdf.Generator.Text();
            // Add a text segment to hold image and text together
            Aspose.Pdf.Generator.Segment seg1 = new Aspose.Pdf.Generator.Segment();
            seg1.InlineParagraph = img;
            txt2.Segments.Add(seg1);

            //Add the image to the table cell
            cell2.Paragraphs.Add(txt2);
            row2.Cells.Add("Aspose Logo is looking very lovely !");
            row2.DefaultCellTextInfo.FontName = "Helvetica";
            // set the vertical allignment of the text as center alligned
            row2.Cells[1].VerticalAlignment = Aspose.Pdf.Generator.VerticalAlignmentType.Center;
            row2.Cells[1].Alignment = Aspose.Pdf.Generator.AlignmentType.Center;

            // save the Pdf file
            pdfConv.Save(dataDir + "Table_in_Header.pdf");
        }
コード例 #13
0
        public static void Run()
        {
            // ExStart:AdvancedHeaderAndFooter
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Sections();

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

            // Create a Section object by calling Add method of Sections collection of Pdf class
            Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();

            // Instantiate First 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(sec1);

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

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

            // Enable this header for first page only
            hf1.IsFirstPageOnly = true;

            // Add Distance From Edge Property to 80 unit Points
            hf1.DistanceFromEdge = 80;

            // Set the First HeaderFooter, top and bottom property respectively
            hf1.Margin.Bottom = 50;
            hf1.Margin.Top    = 100;

            // 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 for first page");

            // Add the text object to the Paragraphs collection of HeaderFooter object to
            // Display header on the pages of PDF document
            hf1.Paragraphs.Add(text);

            /*
             * Second Header "hf2" for odd subsequent pages only
             */

            // Instantiate Second HeaderFooter object and pass the Section reference in which
            // The header or footer is to be added
            Aspose.Pdf.Generator.HeaderFooter hf2 = new Aspose.Pdf.Generator.HeaderFooter(sec1);

            // Set the additional header of odd pages of the PDF document
            sec1.AdditionalOddHeader = hf2;

            // Enable this header for subsequent page only
            hf2.IsSubsequentPagesOnly = true;

            // Add Distance From Edge Property of header to 150 unit Points
            hf2.DistanceFromEdge = 150;
            hf2.Margin.Bottom    = 70;

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

            // Add the text object to the Paragraphs collection of HeaderFooter object to
            // Display header on the pages of PDF document
            hf2.Paragraphs.Add(text);

            /*
             * Third Header "hf3" for even subsequent pages only
             */

            // Instantiate Third HeaderFooter object and pass the Section reference in which
            // The header or footer is to be added
            Aspose.Pdf.Generator.HeaderFooter hf3 = new Aspose.Pdf.Generator.HeaderFooter(sec1);

            // Set the additional header of even pages of the PDF document
            sec1.AdditionalEvenHeader = hf3;

            // Enable this header for subsequent page only
            hf3.IsSubsequentPagesOnly = true;

            // Add the Distance from Edge for the third Header
            hf3.DistanceFromEdge = 180;
            hf3.Margin.Top       = 90;

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

            // Add the text object to the Paragraphs collection of HeaderFooter object to
            // Display header on the pages of PDF document
            hf3.Paragraphs.Add(text);

            // ExEnd:SetHeaderAndFooter
            dataDir = dataDir + "AdvancedHeaderAndFooter_out.pdf";

            // Save Pdf Document
            pdf1.Save(dataDir);
            // ExEnd:AdvancedHeaderAndFooter
            Console.WriteLine("\nAdvanced header and footer setup successfully.\nFile saved at " + dataDir);
        }
コード例 #14
0
        public static void Run()
        {
            // ExStart:AdvancedHeaderAndFooter
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Sections();
            
            // Instantiate a PDF Object 
            Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();

            // Create a Section object by calling Add method of Sections collection of Pdf class
            Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();

            // Instantiate First 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(sec1);

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

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

            // Enable this header for first page only
            hf1.IsFirstPageOnly = true;

            // Add Distance From Edge Property to 80 unit Points
            hf1.DistanceFromEdge = 80;

            // Set the First HeaderFooter, top and bottom property respectively
            hf1.Margin.Bottom = 50;
            hf1.Margin.Top = 100;

            // 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 for first page");

            // Add the text object to the Paragraphs collection of HeaderFooter object to
            // Display header on the pages of PDF document
            hf1.Paragraphs.Add(text);

            /*
             *Second Header "hf2" for odd subsequent pages only
             */

            // Instantiate Second HeaderFooter object and pass the Section reference in which
            // The header or footer is to be added
            Aspose.Pdf.Generator.HeaderFooter hf2 = new Aspose.Pdf.Generator.HeaderFooter(sec1);

            // Set the additional header of odd pages of the PDF document
            sec1.AdditionalOddHeader = hf2;

            // Enable this header for subsequent page only
            hf2.IsSubsequentPagesOnly = true;

            // Add Distance From Edge Property of header to 150 unit Points
            hf2.DistanceFromEdge = 150;
            hf2.Margin.Bottom = 70;

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

            // Add the text object to the Paragraphs collection of HeaderFooter object to
            // Display header on the pages of PDF document
            hf2.Paragraphs.Add(text);

            /*
             *Third Header "hf3" for even subsequent pages only
             */

            // Instantiate Third HeaderFooter object and pass the Section reference in which
            // The header or footer is to be added
            Aspose.Pdf.Generator.HeaderFooter hf3 = new Aspose.Pdf.Generator.HeaderFooter(sec1);

            // Set the additional header of even pages of the PDF document
            sec1.AdditionalEvenHeader = hf3;

            // Enable this header for subsequent page only
            hf3.IsSubsequentPagesOnly = true;

            // Add the Distance from Edge for the third Header
            hf3.DistanceFromEdge = 180;
            hf3.Margin.Top = 90;

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

            // Add the text object to the Paragraphs collection of HeaderFooter object to
            // Display header on the pages of PDF document
            hf3.Paragraphs.Add(text);

            // ExEnd:SetHeaderAndFooter
            dataDir = dataDir + "AdvancedHeaderAndFooter_out.pdf";

            // Save Pdf Document
            pdf1.Save(dataDir);
            // ExEnd:AdvancedHeaderAndFooter
            Console.WriteLine("\nAdvanced header and footer setup successfully.\nFile saved at " + dataDir);
        }