コード例 #1
0
        public static void Run()
        {
            // ExStart:FigureOutTableBreak
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_TechnicalArticles();

            // 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();
            // Instantiate a table object
            Aspose.Pdf.Generator.Table table1 = new Aspose.Pdf.Generator.Table();
            table1.Margin.Top = 300;
            // Add the table in paragraphs collection of the desired section
            section.Paragraphs.Add(table1);
            // Set with column widths of the table
            table1.ColumnWidths = "100 100 100";
            // Set default cell border using BorderInfo object
            table1.DefaultCellBorder = new Aspose.Pdf.Generator.BorderInfo((int)Aspose.Pdf.Generator.BorderSide.All, 0.1F);
            // Set table border using another customized BorderInfo object
            table1.Border = new Aspose.Pdf.Generator.BorderInfo((int)Aspose.Pdf.Generator.BorderSide.All, 1F);
            // Create MarginInfo object and set its left, bottom, right and top margins
            Aspose.Pdf.Generator.MarginInfo margin = new Aspose.Pdf.Generator.MarginInfo();
            margin.Top    = 5f;
            margin.Left   = 5f;
            margin.Right  = 5f;
            margin.Bottom = 5f;
            // Set the default cell padding to the MarginInfo object
            table1.DefaultCellPadding = margin;
            // If you increase the counter to 17, table will break
            // Because it cannot be accommodated any more over this page
            for (int RowCounter = 0; RowCounter <= 16; RowCounter++)
            {
                // Create rows in the table and then cells in the rows
                Aspose.Pdf.Generator.Row row1 = table1.Rows.Add();
                row1.Cells.Add("col " + RowCounter.ToString() + ", 1");
                row1.Cells.Add("col " + RowCounter.ToString() + ", 2");
                row1.Cells.Add("col " + RowCounter.ToString() + ", 3");
            }
            // Get the Page Height information
            float PageHeight = pdf.PageSetup.PageHeight;
            // Get the total height information of Page Top & Bottom margin, table Top margin and table height.
            float TotalObjectsHeight = section.PageInfo.Margin.Top + section.PageInfo.Margin.Bottom + table1.Margin.Top + table1.GetHeight(pdf);

            // Display Page Height, Table Height, table Top margin and Page Top and Bottom margin information
            Console.WriteLine("PDF document Height = " + pdf.PageSetup.PageHeight.ToString() + "\nTop Margin Info = " + section.PageInfo.Margin.Top.ToString() + "\nBottom Margin Info = " + section.PageInfo.Margin.Bottom.ToString() + "\n\nTable-Top Margin Info = " + table1.Margin.Top.ToString() + "\nAverage Row Height = " + table1.Rows[0].GetHeight(pdf).ToString() + " \nTable height " + table1.GetHeight(pdf).ToString() + "\n ----------------------------------------" + "\nTotal Page Height =" + PageHeight.ToString() + "\nCummulative height including Table =" + TotalObjectsHeight.ToString());

            // Check if we deduct the sume of Page top margin + Page Bottom margin + Table Top margin and table height from Page height and its less
            // Than 10 (an average row can be greater than 10)
            if ((PageHeight - TotalObjectsHeight) <= 10)
            {
                // If the value is less than 10, then display the message.
                // Which shows that another row can not be placed and if we add new
                // Row, table will break. It depends upon the row height value.
                Console.WriteLine("Page Height - Objects Height < 10, so table will break");
            }
            // Save the pdf document
            pdf.Save(dataDir + "FigureOutTableBreak_out.pdf");
            // ExEnd:FigureOutTableBreak
        }
コード例 #2
0
        public static void Run()
        {
            // ExStart:NonEnglishText
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Tables();

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

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

            // Instantiate a table object
            Aspose.Pdf.Generator.Table tab1 = new Aspose.Pdf.Generator.Table();

            // Add the table in paragraphs collection of the desired section
            sec1.Paragraphs.Add(tab1);

            // Set with column widths of the table
            tab1.ColumnWidths = "110 120 50";

            // Set default cell border using BorderInfo object
            tab1.DefaultCellBorder = new Aspose.Pdf.Generator.BorderInfo((int)Aspose.Pdf.Generator.BorderSide.All, 0.1F);

            // Set table border using another customized BorderInfo object
            tab1.Border = new Aspose.Pdf.Generator.BorderInfo((int)Aspose.Pdf.Generator.BorderSide.All, 1F);

            // Create MarginInfo object and set its left, bottom, right and top margins
            Aspose.Pdf.Generator.MarginInfo margin = new Aspose.Pdf.Generator.MarginInfo();
            margin.Top    = 5f;
            margin.Left   = 5f;
            margin.Right  = 5f;
            margin.Bottom = 5f;

            // Set the default cell padding to the MarginInfo object
            tab1.DefaultCellPadding = margin;

            // Create rows in the table and then cells in the rows
            Aspose.Pdf.Generator.Row row1 = tab1.Rows.Add();
            row1.DefaultCellTextInfo.FontName = "Arial Unicode MS";
            row1.Cells.Add("Arabic Sample مَرْحَبا بكِ كُلَّ الْتَرْحيبْ");
            row1.Cells[0].DefaultCellTextInfo.IsRightToLeft = true;

            // Row1.Cells[0].DefaultCellTextInfo.FontName = "Arial Unicode MS";
            row1.Cells.Add("Persian alphabet الفبای فارسی");
            row1.Cells[1].DefaultCellTextInfo.IsRightToLeft = true;

            // Row1.Cells[1].DefaultCellTextInfo.FontName = "Arial Unicode MS";
            row1.Cells.Add("English Text");

            // Include the subset of Font supporting Non-English text in PDF file
            pdf1.SetUnicode();

            // Save the Pdf
            pdf1.Save(dataDir + "Arabic_Farsi_Text_in_TableCell_out.pdf");
            // ExEnd:NonEnglishText
        }
コード例 #3
0
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Tables();

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

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

            // Instantiate a table object
            Aspose.Pdf.Generator.Table tab1 = new Aspose.Pdf.Generator.Table();

            // Add the table in paragraphs collection of the desired section
            sec1.Paragraphs.Add(tab1);

            //ExStart:TableRowRepeat
            tab1.IsFirstRowRepeated = true;
            //ExEnd:TableRowRepeat

            //ExStart:TableIsBroken
            tab1.IsBroken = false;
            //ExEnd:TableIsBroken

            // Set with column widths of the table
            tab1.ColumnWidths = "50 50 50";

            // Set default cell border using BorderInfo object
            tab1.DefaultCellBorder = new Aspose.Pdf.Generator.BorderInfo((int)Aspose.Pdf.Generator.BorderSide.All, 0.1F);

            // Set table border using another customized BorderInfo object
            tab1.Border = new Aspose.Pdf.Generator.BorderInfo((int)Aspose.Pdf.Generator.BorderSide.All, 1F);
            // Create MarginInfo object and set its left, bottom, right and top margins
            Aspose.Pdf.Generator.MarginInfo margin = new Aspose.Pdf.Generator.MarginInfo();
            margin.Top    = 5f;
            margin.Left   = 5f;
            margin.Right  = 5f;
            margin.Bottom = 5f;

            // Set the default cell padding to the MarginInfo object
            tab1.DefaultCellPadding = margin;

            // Create rows in the table and then cells in the rows
            Aspose.Pdf.Generator.Row row1 = tab1.Rows.Add();
            row1.Cells.Add("col1");
            row1.Cells.Add("col2");
            row1.Cells.Add("col3");
            Aspose.Pdf.Generator.Row row2 = tab1.Rows.Add();
            row2.Cells.Add("item1");
            row2.Cells.Add("item2");
            row2.Cells.Add("item3");

            // Save the Pdf
            pdf1.Save(dataDir + "TableAndRowSplitting_out_.pdf");
        }
コード例 #4
0
        public static void Run()
        {
            // ExStart:SetTableColumnsWidth
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_TechnicalArticles();

            // Create Pdf Instance
            Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();
            // Create section object and add it to pdf object
            Aspose.Pdf.Generator.Section sec1 = pdf.Sections.Add();

            // Create a table instance
            Aspose.Pdf.Generator.Table mytable = new Aspose.Pdf.Generator.Table();
            // Specify the default border for table object and set its color as Navy
            mytable.DefaultCellBorder = new Aspose.Pdf.Generator.BorderInfo((int)Aspose.Pdf.Generator.BorderSide.All, 1f, new Aspose.Pdf.Generator.Color("Navy"));
            // Specify the border information for table object
            mytable.Border = new Aspose.Pdf.Generator.BorderInfo((int)Aspose.Pdf.Generator.BorderSide.All, 1f, new Aspose.Pdf.Generator.Color("Navy"));
            // Define initial width information for table cells
            mytable.ColumnWidths = "100 100";
            // Create a row object and add it to table
            Aspose.Pdf.Generator.Row row1 = mytable.Rows.Add();
            // Create loop to add specify the number of columns to be added to table row
            for (int Column_Counter = 1; Column_Counter <= 7; Column_Counter++)
            {
                // Create a cell object and add it to table row
                Aspose.Pdf.Generator.Cell Cell = row1.Cells.Add("Cell (1," + Column_Counter.ToString() + ")");
            }
            // Define the variable to keep record of number of columns in table
            int TableColumn = 0;

            // Traverse through each table cell in row object
            foreach (Aspose.Pdf.Generator.Cell InnerCell in row1.Cells)
            {
                // Specify the width information for each column based on section objects margin and width values
                // Set the width value as, get the total width of section and subtract left and right margin and divide
                // It with total number of cells in a particular table row
                mytable.SetColumnWidth(TableColumn, (sec1.PageInfo.PageWidth - sec1.PageInfo.Margin.Left - sec1.PageInfo.Margin.Right) / row1.Cells.Count);
                // Increase the value of variable holding the column count information
                TableColumn += 1;
            }

            // Add table to paragraphs collection of section
            sec1.Paragraphs.Add(mytable);
            // Save the resultant PDF document
            pdf.Save(dataDir + "SetTableColumnsWidth_out.pdf");
            // ExEnd:SetTableColumnsWidth
        }
コード例 #5
0
        public static void Run()
        {
            // ExStart:CellInformation
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Tables();

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

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

            // Create Table instance
            Aspose.Pdf.Generator.Table tab1 = new Aspose.Pdf.Generator.Table();

            // Add the table object in the paragraphs collection of the section
            sec1.Paragraphs.Add(tab1);

            // Set the column widths of the table
            tab1.ColumnWidths = "50 50 50";

            // Set default text color for the text contents of each cell in the table to blue
            tab1.DefaultCellTextInfo.Color = new Aspose.Pdf.Generator.Color("Blue");

            // Set default left side padding of the cell
            tab1.DefaultCellPadding.Left = 5;

            // Set default border of the cell using BorderInfo object
            tab1.DefaultCellBorder = new Aspose.Pdf.Generator.BorderInfo((int)Aspose.Pdf.Generator.BorderSide.All, 0.1F);

            // After setting default cell format information for the table, you can add rows
            // and columns in the table
            Aspose.Pdf.Generator.Row row1 = tab1.Rows.Add();
            row1.Cells.Add("col1");
            row1.Cells.Add("col2");
            row1.Cells.Add("col3");

            // Save the Pdf
            pdf1.Save(dataDir + "CellInformation_out_.pdf");
            // ExEnd:CellInformation
        }
コード例 #6
0
        public static void Run()
        {
            // ExStart:AddImageInTableCell
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_TechnicalArticles();

            // Instantiate a Pdf object
            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();
            // Instantiate a table object
            Aspose.Pdf.Generator.Table tab1 = new Aspose.Pdf.Generator.Table();
            // Add the table in paragraphs collection of the desired section
            sec1.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 = "100 100 120";

            Aspose.Pdf.Generator.Image img = new Aspose.Pdf.Generator.Image();
            img.ImageInfo.File          = dataDir + "aspose-logo.jpg";
            img.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Jpeg;

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

            // Add the cell which holds the image
            Aspose.Pdf.Generator.Cell cell2 = row1.Cells.Add();
            // Add the image to the table cell
            cell2.Paragraphs.Add(img);

            row1.Cells.Add("Previous cell with image");
            row1.Cells[2].VerticalAlignment = Aspose.Pdf.Generator.VerticalAlignmentType.Center;

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

            //Create a section in the pdf document
            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();
            //Instantiate a table object
            Aspose.Pdf.Generator.Table tab1 = new Aspose.Pdf.Generator.Table();
            //Add the table in paragraphs collection of the desired section
            sec1.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 = "100 100 120";

            Aspose.Pdf.Generator.Image img = new Aspose.Pdf.Generator.Image();
            img.ImageInfo.File          = dataDir + "aspose.jpg";
            img.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Jpeg;

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

            // Add the cell which holds the image
            Aspose.Pdf.Generator.Cell cell2 = row1.Cells.Add();
            //Add the image to the table cell
            cell2.Paragraphs.Add(img);

            row1.Cells.Add("Previous cell with image");
            row1.Cells[2].VerticalAlignment = Aspose.Pdf.Generator.VerticalAlignmentType.Center;

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

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

            // Instantiate a table object
            Aspose.Pdf.Generator.Table table1 = new Aspose.Pdf.Generator.Table();
            // Add the table in paragraphs collection of the desired section
            sec1.Paragraphs.Add(table1);
            // Set with column widths of the table
            table1.ColumnWidths = "120 270";

            // Create MarginInfo object and set its left, bottom, right and top margins
            Aspose.Pdf.Generator.MarginInfo margin = new Aspose.Pdf.Generator.MarginInfo();
            margin.Top    = 5f;
            margin.Left   = 5f;
            margin.Right  = 5f;
            margin.Bottom = 5f;
            // Set the default cell padding to the MarginInfo object
            table1.DefaultCellPadding = margin;

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

            // Create an image object
            Aspose.Pdf.Generator.Image logo = new Aspose.Pdf.Generator.Image();
            // Specify the image file path
            logo.ImageInfo.File = dataDir + "aspose-logo.jpg";
            // Specify the image Fixed Height
            logo.ImageInfo.FixHeight = 120;
            // Specify the image Fixed Width
            logo.ImageInfo.FixWidth = 110;
            row1.Cells.Add();
            // Add the image to paragraphs collection of the table cell
            row1.Cells[0].Paragraphs.Add(logo);

            // Create string variables with text containing html tags
            string TitleString = "<font face=\"Arial\" size=6 color=\"#101090\"><b> Aspose.Pdf for .NET</b></font>";

            // Create a text object to be added to the right of image
            Aspose.Pdf.Generator.Text TitleText = new Aspose.Pdf.Generator.Text(TitleString);
            TitleText.IsHtmlTagSupported = true;
            row1.Cells.Add();
            // Add the text paragraphs containing HTML text to the table cell
            row1.Cells[1].Paragraphs.Add(TitleText);
            // Set the vertical alignment of the row contents as Top
            row1.VerticalAlignment = Aspose.Pdf.Generator.VerticalAlignmentType.Top;

            string BodyString1 = "<font face=\"Arial\" size=2><br/>Aspose.Pdf for .NET is a non-graphical PDF® document reporting component that enables .NET applications to <b> create PDF documents from scratch </b> without utilizing Adobe Acrobat®. Aspose.Pdf for .NET is very affordably priced and offers a wealth of strong features including: compression, tables, graphs, images, hyperlinks, security and custom fonts. </font>";

            // Add a text segment to segments collection of the text object
            TitleText.Segments.Add(BodyString1);

            // Create rows in the table and then cells in the rows
            Aspose.Pdf.Generator.Row SecondRow = table1.Rows.Add();
            SecondRow.Cells.Add();
            // Set the row span value for Second row as 2
            SecondRow.Cells[0].ColumnsSpan = 2;
            // Set the vertical alignment of the second row as Top
            SecondRow.VerticalAlignment = Aspose.Pdf.Generator.VerticalAlignmentType.Top;

            string SecondRowString = "<font face=\"Arial\" size=2>Aspose.Pdf for .NET supports the creation of PDF files through API and XML or XSL-FO templates. Aspose.Pdf for .NET is very easy to use and is provided with 14 fully featured demos written in both C# and Visual Basic.</font>";

            Aspose.Pdf.Generator.Text SecondRowText = new Aspose.Pdf.Generator.Text(SecondRowString);
            SecondRowText.IsHtmlTagSupported = true;
            // Add the text paragraphs containing HTML text to the table cell
            SecondRow.Cells[0].Paragraphs.Add(SecondRowText);
            // Save the Pdf file
            pdf1.Save(dataDir + "PlacingTextAroundImage_out.pdf");
            // ExEnd:PlacingTextAroundImage
        }
コード例 #9
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");
        }
コード例 #10
0
        public static void RadioButtonWithCustomPosition()
        {
            // ExStart:RadioButtonWithCustomPosition
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_UtilityFeatures();

            // Instantiate the Pdf document and add a section to it
            Aspose.Pdf.Generator.Pdf     pdf1 = new Aspose.Pdf.Generator.Pdf();
            Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();


            // Create a table, set its column widths and add it to paragraphs collection
            // of the  section
            Aspose.Pdf.Generator.Table tab1 = new Aspose.Pdf.Generator.Table();
            tab1.ColumnWidths = "120 120 120";
            sec1.Paragraphs.Add(tab1);


            // Add a row to the table
            Aspose.Pdf.Generator.Row r1 = tab1.Rows.Add();


            // Add 1st cell to the row, set its padding and set the ID of the first paragraph
            // in the cell to "text1"
            Aspose.Pdf.Generator.Cell c1 = r1.Cells.Add("item1");
            c1.Padding.Left     = 30;
            c1.Paragraphs[0].ID = "text1";


            // Add 2nd cell to the row, set its padding and set the ID of the first paragraph
            // in the cell to "text2"
            Aspose.Pdf.Generator.Cell c2 = r1.Cells.Add("item2");
            c2.Padding.Left     = 30;
            c2.Paragraphs[0].ID = "text2";


            // Add 3rd cell to the row, set its padding and set the ID of the first paragraph
            // in the cell to "text3"
            Aspose.Pdf.Generator.Cell c3 = r1.Cells.Add("item3");
            c3.Padding.Left     = 30;
            c3.Paragraphs[0].ID = "text3";


            // Create a form field of RadioButton type. Set its field name and button color.
            // Then set the index of the radio button value to be checked
            Aspose.Pdf.Generator.FormField radio = new Aspose.Pdf.Generator.FormField();
            radio.FormFieldType           = Aspose.Pdf.Generator.FormFieldType.RadioButton;
            radio.FieldName               = "ARadio";
            radio.ButtonColor             = System.Drawing.Color.FromName("Red");
            radio.RadioButtonCheckedIndex = 0;


            // Create 1st radio button instance and add it to above created radio form field.
            // Set its width and height. The position of the radio button is set to be
            // relative to the paragraph. Link this radio button with the paragraph with ID
            // equal to "text1".
            Aspose.Pdf.Generator.RadioButton bt1 = radio.RadioButtons.Add();
            bt1.ButtonHeight         = 12;
            bt1.ButtonWidth          = 12;
            bt1.PositioningType      = Aspose.Pdf.Generator.PositioningType.ParagraphRelative;
            bt1.ReferenceParagraphID = "text1";
            bt1.Left = -20;
            bt1.Top  = 0;


            // Create 2nd radio button instance and add it to above created radio form field.
            // Set its width and height. The position of the radio button is set to be
            // relative to the paragraph. Link this radio button with the paragraph with ID
            // equal to "text2".
            Aspose.Pdf.Generator.RadioButton bt2 = radio.RadioButtons.Add();
            bt2.ButtonHeight         = 12;
            bt2.ButtonWidth          = 12;
            bt2.PositioningType      = Aspose.Pdf.Generator.PositioningType.ParagraphRelative;
            bt2.ReferenceParagraphID = "text2";
            bt2.Left = -20;
            bt2.Top  = 0;


            // Create 3rd radio button instance and add it to above created radio form field.
            // Set its width and height. The position of the radio button is set to be
            // relative to the paragraph. Link this radio button with the paragraph with ID
            // equal to "text3".
            Aspose.Pdf.Generator.RadioButton bt3 = radio.RadioButtons.Add();
            bt3.ButtonHeight         = 12;
            bt3.ButtonWidth          = 12;
            bt3.PositioningType      = Aspose.Pdf.Generator.PositioningType.ParagraphRelative;
            bt3.ReferenceParagraphID = "text3";
            bt3.Left = -20;
            bt3.Top  = 0;


            // Add the radio form field to the paragraphs collection of the section
            sec1.Paragraphs.Add(radio);

            dataDir = dataDir + "RadioButtonWithCustomPosition_out_.pdf";
            // Save the Pdf
            pdf1.Save(dataDir);
            // ExEnd:RadioButtonWithCustomPosition
        }
コード例 #11
0
        public static void Run()
        {
            // ExStart:RoundedCornerTable
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Tables();

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

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

            // Instantiate a table object
            Aspose.Pdf.Generator.Table tab1 = new Aspose.Pdf.Generator.Table();

            // Add the table in paragraphs collection of the desired section
            sec1.Paragraphs.Add(tab1);

            // Set with column widths of the table
            tab1.ColumnWidths = "100";

            // Set fixed table row height
            tab1.FixedHeight = 30;

            // Create a blank BorderInfo object
            Aspose.Pdf.Generator.BorderInfo bInfo = new Aspose.Pdf.Generator.BorderInfo();

            // Create a GraphInfo object without any argument to its constructor
            Aspose.Pdf.Generator.GraphInfo gInfo = new Aspose.Pdf.Generator.GraphInfo();

            // Set the corner radius for GraphInfo
            gInfo.CornerRadius = 15F;

            // Specify the line color information
            gInfo.Color = new Aspose.Pdf.Generator.Color("Red");

            // Set the rounded corner table border
            bInfo.Round = gInfo;

            // Specify the Corner style for table border as Round
            tab1.CornerStyle = Aspose.Pdf.Generator.BorderCornerStyle.Round;

            // Set the table border information
            tab1.Border = bInfo;

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

            // Add sample string to paragraphs collection of table cell
            row1.Cells.Add("Hello World...");

            // Set the vertical alignment of text as center aligned
            row1.Cells[0].DefaultCellTextInfo.Alignment = Aspose.Pdf.Generator.AlignmentType.Center;

            // Set the horizontal alignment of text as center aligned
            row1.Cells[0].VerticalAlignment = Aspose.Pdf.Generator.VerticalAlignmentType.Center;

            // Save the Pdf
            pdf1.Save(dataDir + "Rounded_Corner-Table_out.pdf");
            // ExEnd:RoundedCornerTable
        }
コード例 #12
0
        public static void Run()
        {
            // ExStart:NestedTables
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Tables();

            // 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 a table
            Aspose.Pdf.Generator.Table tab1 = new Aspose.Pdf.Generator.Table();

            // Add the table into the paragraphs collection of section
            sec1.Paragraphs.Add(tab1);

            // Set the column widths of the table
            tab1.ColumnWidths = "100 200";

            // Set the default cell border using BorderInfo instance
            tab1.DefaultCellBorder = new Aspose.Pdf.Generator.BorderInfo((int)Aspose.Pdf.Generator.BorderSide.All);

            // Add a row into the table
            Aspose.Pdf.Generator.Row row1 = tab1.Rows.Add();

            // Add 1st cell in the row
            row1.Cells.Add("left cell");

            // Add 2nd cell in the row
            Aspose.Pdf.Generator.Cell cell2 = row1.Cells.Add();

            // Create a table to be nested with the reference of 2nd cell in the row
            Aspose.Pdf.Generator.Table tab2 = new Aspose.Pdf.Generator.Table(cell2);

            // Add the nested table into the paragraphs collection of the 2nd cell
            cell2.Paragraphs.Add(tab2);

            // Set the column widths of the nested table
            tab2.ColumnWidths = "100 100";

            // Create 1st row in the nested table
            Aspose.Pdf.Generator.Row row21 = tab2.Rows.Add();

            // Create 1st cell in the 1st row of the nested table
            Aspose.Pdf.Generator.Cell cell21 = row21.Cells.Add("top cell");

            // Set the column span of the 1st cell (in the 1st row of the nested table) to 2
            cell21.ColumnsSpan = 2;

            // Create 2nd row in the nested table
            Aspose.Pdf.Generator.Row row22 = tab2.Rows.Add();

            // Create 1st cell in the 2nd row of the nested table
            row22.Cells.Add("left bottom cell");

            // Create 2nd cell in the 2nd row of the nested table
            row22.Cells.Add("right bottom cell");

            // Save the Pdf
            pdf1.Save(dataDir + "NestedTables_out.pdf");
            // ExEnd:NestedTables
        }
コード例 #13
0
        public static void Run()
        {
            // ExStart:IntegrateWithDatabase
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Tables();

            DataTable dt = new DataTable("Employee");

            dt.Columns.Add("Employee_ID", typeof(Int32));
            dt.Columns.Add("Employee_Name", typeof(string));
            dt.Columns.Add("Gender", typeof(string));

            // Add 2 rows into the DataTable object programmatically

            DataRow dr = dt.NewRow();

            dr[0] = 1;
            dr[1] = "John Smith";
            dr[2] = "Male";
            dt.Rows.Add(dr);

            dr    = dt.NewRow();
            dr[0] = 2;
            dr[1] = "Mary Miller";
            dr[2] = "Female";
            dt.Rows.Add(dr);

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

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

            // Create a Table object
            Aspose.Pdf.Generator.Table tab1 = new Aspose.Pdf.Generator.Table();


            // Add the Table object in the paragraphs collection of the section
            sec1.Paragraphs.Add(tab1);

            // Set column widths of the table
            tab1.ColumnWidths = "40 100 100 100";

            // Set default cell border of the table using BorderInfo object
            tab1.DefaultCellBorder = new Aspose.Pdf.Generator.BorderInfo((int)Aspose.Pdf.Generator.BorderSide.All, 0.1F);

            // Import data into the Table object from the DataTable created above
            tab1.ImportDataTable(dt, true, 0, 1, 3, 3);

            // Get 1st row from the table
            Aspose.Pdf.Generator.Row row1 = tab1.Rows[0];

            // Iterate through all cells in the row and set their background color to blue
            foreach (Aspose.Pdf.Generator.Cell curCell in row1.Cells)
            {
                curCell.BackgroundColor = new Aspose.Pdf.Generator.Color("Blue");
            }

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