Beispiel #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
        }
Beispiel #2
0
        public static void Run()
        {
            // ExStart:LoadDataInXMLTemplate
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_AdvanceFeatures();

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

            // Binding the content from the named XML file
            pdf.BindXML(dataDir + "Sample.xml", null);

            // In a real scenario, data is usually input from Database. So, we can get data
            // From a database. In this case, we are using a method that will provide us an
            // Instance of DataTable. The implementation of this method is also given below.
            DataTable getDT = creatDataTable();

            // Accessing a table through its ID
            Aspose.Pdf.Generator.Table contenTable = (Aspose.Pdf.Generator.Table)pdf.GetObjectByID("Content");

            // Importing data from a DataTable and filling the table in PDF document
            contenTable.ImportDataTable(getDT, false, 1, 1, 5, 4);

            // Saving the results
            pdf.Save(dataDir + "Sample_out.pdf");
            // ExEnd:LoadDataInXMLTemplate
        }
        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   
                
        }
        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");            
                
        }
        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           
        }
        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   
                
        }
        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
        }
        public static void Run()
        {
            // ExStart:RowAndColumnFormat
            // 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 table in the paragraphs collection of the section
            sec1.Paragraphs.Add(tab1);

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

            // Create a TextInfo instance
            Aspose.Pdf.Generator.TextInfo tinfo = new Aspose.Pdf.Generator.TextInfo();

            // Set the font name to "Courier" for the TextInfo object
            tinfo.FontName = "Courier";

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

            // Apply the text format settings in TextInfo object to table cells
            tab1.DefaultCellTextInfo = tinfo;

            // Create an array of double values
            double[] darr = new Double[] { 1.5, 3.1415926, 100000, 20, 4000, 30.4512, 45.67, 890, 23.45 };

            // Import the values in array to table
            tab1.ImportArray(darr, 0, 0, false);

            // Set background color for the first row 
            Aspose.Pdf.Generator.TextInfo tinfo1 = tinfo.Clone() as Aspose.Pdf.Generator.TextInfo;
            tinfo1.BackgroundColor = new Aspose.Pdf.Generator.Color("#0000ff");
            tab1.Rows[0].DefaultCellTextInfo = tinfo1;

            // Align text in the last column to right hand side
            Aspose.Pdf.Generator.TextInfo tinfo2 = tinfo.Clone() as Aspose.Pdf.Generator.TextInfo;
            tinfo2.Alignment = Aspose.Pdf.Generator.AlignmentType.Right;
            tab1.SetColumnTextInfo(2, tinfo2);

            // We have to reset text format settings of the upper right cell 
            tinfo1.Alignment = Aspose.Pdf.Generator.AlignmentType.Right;
            tab1.Rows[0].Cells[2].DefaultCellTextInfo = tinfo1; 
            
            // Save the Pdf
            pdf1.Save(dataDir + "RowAndColumnFormat_out.pdf");
            // ExEnd:RowAndColumnFormat   
                
        }
        public static void Run()
        {
            // ExStart:RowAndColumnFormat
            // 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 table in the paragraphs collection of the section
            sec1.Paragraphs.Add(tab1);

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

            // Create a TextInfo instance
            Aspose.Pdf.Generator.TextInfo tinfo = new Aspose.Pdf.Generator.TextInfo();

            // Set the font name to "Courier" for the TextInfo object
            tinfo.FontName = "Courier";

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

            // Apply the text format settings in TextInfo object to table cells
            tab1.DefaultCellTextInfo = tinfo;

            // Create an array of double values
            double[] darr = new Double[] { 1.5, 3.1415926, 100000, 20, 4000, 30.4512, 45.67, 890, 23.45 };

            // Import the values in array to table
            tab1.ImportArray(darr, 0, 0, false);

            // Set background color for the first row
            Aspose.Pdf.Generator.TextInfo tinfo1 = tinfo.Clone() as Aspose.Pdf.Generator.TextInfo;
            tinfo1.BackgroundColor           = new Aspose.Pdf.Generator.Color("#0000ff");
            tab1.Rows[0].DefaultCellTextInfo = tinfo1;

            // Align text in the last column to right hand side
            Aspose.Pdf.Generator.TextInfo tinfo2 = tinfo.Clone() as Aspose.Pdf.Generator.TextInfo;
            tinfo2.Alignment = Aspose.Pdf.Generator.AlignmentType.Right;
            tab1.SetColumnTextInfo(2, tinfo2);

            // We have to reset text format settings of the upper right cell
            tinfo1.Alignment = Aspose.Pdf.Generator.AlignmentType.Right;
            tab1.Rows[0].Cells[2].DefaultCellTextInfo = tinfo1;

            // Save the Pdf
            pdf1.Save(dataDir + "RowAndColumnFormat_out_.pdf");
            // ExEnd:RowAndColumnFormat
        }
        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");
        }
        public static void Run()
        {
            // ExStart:XMLAsTemplate
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_AdvanceFeatures();

            // Create a Pdf instance and bind the XML template file to Pdf instance
            Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
            pdf1.BindXML(dataDir + "Template.xml", null);

            // Get the section and then table from the obtained section of the Pdf that
            // is built from the XML template
            Aspose.Pdf.Generator.Section sec1   = pdf1.Sections["Section1"];
            Aspose.Pdf.Generator.Table   table1 = sec1.Paragraphs["Table1"] as Aspose.Pdf.Generator.Table;

            // Clone a new table
            Aspose.Pdf.Generator.Table table2 = table1.CompleteClone() as Aspose.Pdf.Generator.Table;

            // Change the ID of table2 to "Table2" to make it different from table1
            table2.ID = "Table2";

            // Add table2 into the section
            sec1.Paragraphs.Add(table2);

            // Now there are 2 segments with ID "Item",
            // We change the IDs to make sure they are different
            Aspose.Pdf.Generator.Segment item = sec1.GetObjectByID("Item") as Aspose.Pdf.Generator.Segment;
            item.ID = "Item1";
            item    = sec1.GetObjectByID("Item") as Aspose.Pdf.Generator.Segment;
            item.ID = "Item2";

            // Change the content
            item.Content = "item 2";

            // Now clone section1
            Aspose.Pdf.Generator.Section sec2 = sec1.CompleteClone() as Aspose.Pdf.Generator.Section;

            // Add a cloned section to the Pdf and change the contents of the text segments
            // in the section2 of the Pdf object
            pdf1.Sections.Add(sec2);
            item         = sec2.GetObjectByID("Item1") as Aspose.Pdf.Generator.Segment;
            item.Content = "item1 sec2";
            item         = sec2.GetObjectByID("Item2") as Aspose.Pdf.Generator.Segment;
            item.Content = "item2 sec2";

            // Save the Pdf
            pdf1.Save(dataDir + "XmlTemp_out_.pdf");
            // ExEnd:XMLAsTemplate
        }
Beispiel #12
0
        public static void Run()
        {
            // ExStart:CompleteClone
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Tables();

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

            // Call BindXML method to read information from RepeatExample.xml document. Second
            // parameter is for Xsl file. In our case, we don't need it so leave it as null.
            pdf1.BindXML(dataDir + "RepeatExample.xml", null);

            // Obtain the first section from the Pdf
            Aspose.Pdf.Generator.Section sec1 = pdf1.Sections[0];

            // Obtain a table named "table1" from the Pdf
            Aspose.Pdf.Generator.Table table1 = sec1.Paragraphs["table1"] as Aspose.Pdf.Generator.Table;

            // Declare a table instance
            Aspose.Pdf.Generator.Table curTable;

            // Create an array of string containing three values, "item1", "item2" and "item3"
            string[] items = new string[] { "item1", "item2", "item3" };

            // Run a for loop for 5 times
            for (int i = 0; i < 5; i++)
            {
                // Copy the table structure of "table1" by calling its Clone method
                curTable = table1.Clone() as Aspose.Pdf.Generator.Table;

                // Set the top margin of the cloned table to 10
                curTable.Margin.Top = 10;

                // Copy a row (with structure and data) of "table1" by calling its
                // CompleteClone method. And then add that row to the cloned table
                curTable.Rows.Add(table1.Rows[0].CompleteClone() as Aspose.Pdf.Generator.Row);

                // Import an array of string "items" into the table
                curTable.ImportArray(items, 1, 0, false);

                // Add the cloned table to the paragraphs collection of the section
                sec1.Paragraphs.Add(curTable);
            }

            // Save the Pdf
            pdf1.Save(dataDir + "CompleteClone_out_.pdf");
            // ExEnd:CompleteClone
        }
        public static void Run()
        {
            // ExStart:DisplayCurrencySymbol
            // Create an object of TableFormatInfo class.
            Aspose.Pdf.Generator.TableFormatInfo tfi = new Aspose.Pdf.Generator.TableFormatInfo();

            // Sets a string value that indicate currency symbol of money, the default is "$".
            tfi.CurrencySymbol = "$";
            // Instantiate a table object
            Aspose.Pdf.Generator.Table tab1 = new Aspose.Pdf.Generator.Table();

            // Format the table in specified columns and rows with given TableFormatInfo
            tab1.FormatTableWithFormatInfo(tfi, 1, 1, 1, 1);
            // ExEnd:DisplayCurrencySymbol
        }
        public static void Run()
        {
            // ExStart:DisplayCurrencySymbol           
            // Create an object of TableFormatInfo class.
            Aspose.Pdf.Generator.TableFormatInfo tfi = new Aspose.Pdf.Generator.TableFormatInfo();

            // Sets a string value that indicate currency symbol of money, the default is "$".
            tfi.CurrencySymbol = "$";
            // Instantiate a table object
            Aspose.Pdf.Generator.Table tab1 = new Aspose.Pdf.Generator.Table();

            // Format the table in specified columns and rows with given TableFormatInfo
            tab1.FormatTableWithFormatInfo(tfi, 1, 1, 1, 1);
            // ExEnd:DisplayCurrencySymbol           
        }
Beispiel #15
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
        }
        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           
        }
        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   
                
        }
Beispiel #18
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
        }
        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
        }
        public static void Run()
        {
            // ExStart:TableMinimumColumnWidth
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_AdvanceFeatures();

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

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

            // Create a table object and add it to the paragraphs collection of the section
            Aspose.Pdf.Generator.Table tab1 = new Aspose.Pdf.Generator.Table();
            sec1.Paragraphs.Add(tab1);

            // Set the column widths and default cell border of the table
            tab1.ColumnWidths      = "60 100 100";
            tab1.DefaultCellBorder = new Aspose.Pdf.Generator.BorderInfo((int)Aspose.Pdf.Generator.BorderSide.All, 1F);

            // Prepare an array of string values to be added to table
            string[] darr = new string[]
            { "Owner/Marketing Assistant", "dhasf hh ddt", "dhaosdha djsd dsads",
              "dsd dajd", "hdsah jj jj jdj", "ddfa jjj jhdusa" };

            // Import the contents of the array created in above step
            tab1.ImportArray(darr, 0, 0, true);

            // Call GetMinColumnWidth and pass the column number whose minimum width is needed
            float width = tab1.GetMinColumnWidth(pdf1, 0);

            // Call SetColumnWidth and pass the column number with minimum width
            tab1.SetColumnWidth(0, width);

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

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

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

            // Create a table object and add it to the paragraphs collection of the section        
            Aspose.Pdf.Generator.Table tab1 = new Aspose.Pdf.Generator.Table();
            sec1.Paragraphs.Add(tab1);

            // Set the column widths and default cell border of the table
            tab1.ColumnWidths = "60 100 100";
            tab1.DefaultCellBorder = new Aspose.Pdf.Generator.BorderInfo((int)Aspose.Pdf.Generator.BorderSide.All, 1F);

            // Prepare an array of string values to be added to table
            string[] darr = new string[]
        {"Owner/Marketing Assistant","dhasf hh ddt", "dhaosdha djsd dsads",
                "dsd dajd", "hdsah jj jj jdj", "ddfa jjj jhdusa"};

            // Import the contents of the array created in above step
            tab1.ImportArray(darr, 0, 0, true);

            // Call GetMinColumnWidth and pass the column number whose minimum width is needed
            float width = tab1.GetMinColumnWidth(pdf1, 0);

            // Call SetColumnWidth and pass the column number with minimum width
            tab1.SetColumnWidth(0, width);                                

            dataDir = dataDir + "TableMinimumColumnWidth_out.pdf";
            // Save the Pdf
            pdf1.Save(dataDir);
            // ExEnd:TableMinimumColumnWidth           
        }
        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           
        }
        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");
        }
        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");
        }
Beispiel #25
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");
        }
        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");
        }
        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
        }
        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
        }
        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   
                
        }
        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           
        }
        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           
        }
        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   
                
        }
Beispiel #33
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
        }
        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
        }
Beispiel #35
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
        }