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

            // Instantiate Document object
            Document doc = new Document();
            // Add page to PDF document
            Page page = doc.Pages.Add();

            // Create BorderInfo object
            Aspose.Pdf.BorderInfo border = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All);
            // Specify that Top border will be double
            border.Top.IsDoubled = true;
            // Specify that bottom border will be double
            border.Bottom.IsDoubled = true;
            // Instantiate Table object
            Aspose.Pdf.Table table = new Aspose.Pdf.Table();
            // Specify Columns width information
            table.ColumnWidths = "100";
            // Create Row object
            Aspose.Pdf.Row row = table.Rows.Add();
            // Add a Table cell to cells collection of row
            Aspose.Pdf.Cell cell = row.Cells.Add("some text");
            // Set the border for cell object (double border)
            cell.Border = border;
            // Add table to paragraphs collection of Page
            page.Paragraphs.Add(table);
            dataDir = dataDir + "TableBorderTest_out_.pdf";
            // Save the PDF document
            doc.Save(dataDir);
            // ExEnd:SetBorder
            Console.WriteLine("\nBorder setup successfully.\nFile saved at " + dataDir);
        }
 public static void Run()
 {
     // ExStart:SetBorder
     // The path to the documents directory.
     string dataDir = RunExamples.GetDataDir_AsposePdf_Tables();
    
     // Instantiate Document object
     Document doc = new Document();
     // Add page to PDF document
     Page page = doc.Pages.Add();
     // Create BorderInfo object
     Aspose.Pdf.BorderInfo border = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All);
     // Specify that Top border will be double
     border.Top.IsDoubled = true;
     // Specify that bottom border will be double
     border.Bottom.IsDoubled = true;
     // Instantiate Table object
     Aspose.Pdf.Table table = new Aspose.Pdf.Table();
     // Specify Columns width information
     table.ColumnWidths = "100";
     // Create Row object
     Aspose.Pdf.Row row = table.Rows.Add();
     // Add a Table cell to cells collection of row
     Aspose.Pdf.Cell cell = row.Cells.Add("some text");
     // Set the border for cell object (double border)
     cell.Border = border;
     // Add table to paragraphs collection of Page
     page.Paragraphs.Add(table);
     dataDir = dataDir + "TableBorderTest_out.pdf";
     // Save the PDF document
     doc.Save(dataDir);
     // ExEnd:SetBorder
     Console.WriteLine("\nBorder setup successfully.\nFile saved at " + dataDir);
     
 }
Exemple #3
0
        public static void AddImageAndTable()
        {
            // ExStart:AddImageAndTable
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Text();

            Document     doc  = new Document();
            Page         page = doc.Pages.Add();
            TextFragment text = new TextFragment("some text");

            page.Paragraphs.Add(text);

            text.FootNote = new Note();
            Aspose.Pdf.Image image = new Aspose.Pdf.Image();
            image.File      = dataDir + "aspose-logo.jpg";
            image.FixHeight = 20;
            text.FootNote.Paragraphs.Add(image);
            TextFragment footNote = new TextFragment("footnote text");

            footNote.TextState.FontSize = 20;
            footNote.IsInLineParagraph  = true;
            text.FootNote.Paragraphs.Add(footNote);
            Aspose.Pdf.Table table = new Aspose.Pdf.Table();
            table.Rows.Add().Cells.Add().Paragraphs.Add(new TextFragment("Row 1 Cell 1"));
            text.FootNote.Paragraphs.Add(table);

            dataDir = dataDir + "AddImageAndTable_out.pdf";

            // Save resulting PDF document.
            doc.Save(dataDir);
            // ExEnd:AddImageAndTable
            Console.WriteLine("\nTable and image added successfully to FootNote.\nFile saved at " + dataDir);
        }
        public static void Main(string[] args)
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");

            // Load source PDF document
            Aspose.Pdf.Document doc = new Aspose.Pdf.Document(dataDir + "input.pdf");
            // Initializes a new instance of the Table
            Aspose.Pdf.Table table = new Aspose.Pdf.Table();
            // Set the table border color as LightGray
            table.Border = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, .5f, Aspose.Pdf.Color.FromRgb(System.Drawing.Color.LightGray));
            // set the border for table cells
            table.DefaultCellBorder = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, .5f, Aspose.Pdf.Color.FromRgb(System.Drawing.Color.LightGray));
            // create a loop to add 10 rows
            for (int row_count = 1; row_count < 10; row_count++)
            {
                // add row to table
                Aspose.Pdf.Row row = table.Rows.Add();
                // add table cells
                row.Cells.Add("Column (" + row_count + ", 1)");
                row.Cells.Add("Column (" + row_count + ", 2)");
                row.Cells.Add("Column (" + row_count + ", 3)");
            }
            // Add table object to first page of input document
            doc.Pages[1].Paragraphs.Add(table);
            // Save updated document containing table object
            doc.Save(dataDir + "document_with_table.pdf");
        }
Exemple #5
0
        public static void Run()
        {
            // ExStart:AddTable
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Tables();

            // Load source PDF document
            Aspose.Pdf.Document doc = new Aspose.Pdf.Document(dataDir + "AddTable.pdf");
            // Initializes a new instance of the Table
            Aspose.Pdf.Table table = new Aspose.Pdf.Table();
            // Set the table border color as LightGray
            table.Border = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, .5f, Aspose.Pdf.Color.FromRgb(System.Drawing.Color.LightGray));
            // Set the border for table cells
            table.DefaultCellBorder = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, .5f, Aspose.Pdf.Color.FromRgb(System.Drawing.Color.LightGray));
            // Create a loop to add 10 rows
            for (int row_count = 1; row_count < 10; row_count++)
            {
                // Add row to table
                Aspose.Pdf.Row row = table.Rows.Add();
                // Add table cells
                row.Cells.Add("Column (" + row_count + ", 1)");
                row.Cells.Add("Column (" + row_count + ", 2)");
                row.Cells.Add("Column (" + row_count + ", 3)");
            }
            // Add table object to first page of input document
            doc.Pages[1].Paragraphs.Add(table);
            dataDir = dataDir + "document_with_table_out.pdf";
            // Save updated document containing table object
            doc.Save(dataDir);
            // ExEnd:AddTable
            Console.WriteLine("\nText added successfully to an existing pdf file.\nFile saved at " + dataDir);
        }
        public static void Run()
        {
            // ExStart:AddTable
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Tables();

            // Load source PDF document
            Aspose.Pdf.Document doc = new Aspose.Pdf.Document(dataDir+ "AddTable.pdf");
            // Initializes a new instance of the Table
            Aspose.Pdf.Table table = new Aspose.Pdf.Table();
            // Set the table border color as LightGray
            table.Border = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, .5f, Aspose.Pdf.Color.FromRgb(System.Drawing.Color.LightGray));
            // Set the border for table cells
            table.DefaultCellBorder = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, .5f, Aspose.Pdf.Color.FromRgb(System.Drawing.Color.LightGray));
            // Create a loop to add 10 rows
            for (int row_count = 1; row_count < 10; row_count++)
            {
                // Add row to table
                Aspose.Pdf.Row row = table.Rows.Add();
                // Add table cells
                row.Cells.Add("Column (" + row_count + ", 1)");
                row.Cells.Add("Column (" + row_count + ", 2)");
                row.Cells.Add("Column (" + row_count + ", 3)");
            }
            // Add table object to first page of input document
            doc.Pages[1].Paragraphs.Add(table);
            dataDir = dataDir + "document_with_table_out.pdf";
            // Save updated document containing table object
            doc.Save(dataDir);
            // ExEnd:AddTable
            Console.WriteLine("\nText added successfully to an existing pdf file.\nFile saved at " + dataDir);            
        }
        public static void Main(string[] args)
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");

            // Load source PDF document
            Aspose.Pdf.Document doc = new Aspose.Pdf.Document(dataDir+ "input.pdf");
            // Initializes a new instance of the Table
            Aspose.Pdf.Table table = new Aspose.Pdf.Table();
            // Set the table border color as LightGray
            table.Border = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, .5f, Aspose.Pdf.Color.FromRgb(System.Drawing.Color.LightGray));
            // set the border for table cells
            table.DefaultCellBorder = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, .5f, Aspose.Pdf.Color.FromRgb(System.Drawing.Color.LightGray));
            // create a loop to add 10 rows
            for (int row_count = 1; row_count < 10; row_count++)
            {
                // add row to table
                Aspose.Pdf.Row row = table.Rows.Add();
                // add table cells
                row.Cells.Add("Column (" + row_count + ", 1)");
                row.Cells.Add("Column (" + row_count + ", 2)");
                row.Cells.Add("Column (" + row_count + ", 3)");
            }
            // Add table object to first page of input document
            doc.Pages[1].Paragraphs.Add(table);
            // Save updated document containing table object
            doc.Save(dataDir+ "document_with_table.pdf");
        }
Exemple #8
0
        public static void Main(string[] args)
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");

            // Create directory if it is not already present.
            bool IsExists = System.IO.Directory.Exists(dataDir);

            if (!IsExists)
            {
                System.IO.Directory.CreateDirectory(dataDir);
            }


            Document doc      = new Document();
            PageInfo pageInfo = doc.PageInfo;

            Aspose.Pdf.MarginInfo marginInfo = pageInfo.Margin;

            marginInfo.Left   = 37;
            marginInfo.Right  = 37;
            marginInfo.Top    = 37;
            marginInfo.Bottom = 37;

            pageInfo.IsLandscape = true;

            Aspose.Pdf.Table table = new Aspose.Pdf.Table();
            table.ColumnWidths = "50 100";
            // Added page.
            Page curPage = doc.Pages.Add();

            for (int i = 1; i <= 120; i++)
            {
                Aspose.Pdf.Row row = table.Rows.Add();
                row.FixedRowHeight = 15;
                Aspose.Pdf.Cell cell1 = row.Cells.Add();
                cell1.Paragraphs.Add(new TextFragment("Content 1"));
                Aspose.Pdf.Cell cell2 = row.Cells.Add();
                cell2.Paragraphs.Add(new TextFragment("HHHHH"));
            }
            Aspose.Pdf.Paragraphs paragraphs = curPage.Paragraphs;
            paragraphs.Add(table);
            /********************************************/
            Aspose.Pdf.Table table1 = new Aspose.Pdf.Table();
            table.ColumnWidths = "100 100";
            for (int i = 1; i <= 10; i++)
            {
                Aspose.Pdf.Row  row   = table1.Rows.Add();
                Aspose.Pdf.Cell cell1 = row.Cells.Add();
                cell1.Paragraphs.Add(new TextFragment("LAAAAAAA"));
                Aspose.Pdf.Cell cell2 = row.Cells.Add();
                cell2.Paragraphs.Add(new TextFragment("LAAGGGGGG"));
            }
            table1.IsInNewPage = true;
            // I want to keep table 1 to next page please...
            paragraphs.Add(table1);

            doc.Save(dataDir + "IsNewPageProperty_Test.pdf");
        }
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Tables();

            // Create directory if it is not already present.
            bool IsExists = System.IO.Directory.Exists(dataDir);
            if (!IsExists)
                System.IO.Directory.CreateDirectory(dataDir);


            Document doc = new Document();
            PageInfo pageInfo = doc.PageInfo;
            Aspose.Pdf.MarginInfo marginInfo = pageInfo.Margin;

            marginInfo.Left = 37;
            marginInfo.Right = 37;
            marginInfo.Top = 37;
            marginInfo.Bottom = 37;

            pageInfo.IsLandscape = true;

            Aspose.Pdf.Table table = new Aspose.Pdf.Table();
            table.ColumnWidths = "50 100";
            // Added page.
            Page curPage = doc.Pages.Add();
            for (int i = 1; i <= 120; i++)
            {
                Aspose.Pdf.Row row = table.Rows.Add();
                row.FixedRowHeight = 15;
                Aspose.Pdf.Cell cell1 = row.Cells.Add();
                cell1.Paragraphs.Add(new TextFragment("Content 1"));
                Aspose.Pdf.Cell cell2 = row.Cells.Add();
                cell2.Paragraphs.Add(new TextFragment("HHHHH"));
            }
            Aspose.Pdf.Paragraphs paragraphs = curPage.Paragraphs;
            paragraphs.Add(table);
            /********************************************/
            Aspose.Pdf.Table table1 = new Aspose.Pdf.Table();
            table.ColumnWidths = "100 100";
            for (int i = 1; i <= 10; i++)
            {
                Aspose.Pdf.Row row = table1.Rows.Add();
                Aspose.Pdf.Cell cell1 = row.Cells.Add();
                cell1.Paragraphs.Add(new TextFragment("LAAAAAAA"));
                Aspose.Pdf.Cell cell2 = row.Cells.Add();
                cell2.Paragraphs.Add(new TextFragment("LAAGGGGGG"));
            }
            table1.IsInNewPage = true;
            // I want to keep table 1 to next page please...
            paragraphs.Add(table1);

            doc.Save(dataDir+ "IsNewPageProperty_Test.pdf");
            
            
        }
Exemple #10
0
        public static void Main(string[] args)
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");

            // Create directory if it is not already present.
            bool IsExists = System.IO.Directory.Exists(dataDir);

            if (!IsExists)
            {
                System.IO.Directory.CreateDirectory(dataDir);
            }


            //Instntiate the Document object by calling its empty constructor
            Document doc  = new Document();
            Page     page = doc.Pages.Add();

            //Instantiate a table object
            Aspose.Pdf.Table tab1 = new Aspose.Pdf.Table();
            //Add the table in paragraphs collection of the desired section
            page.Paragraphs.Add(tab1);
            //Set with column widths of the table
            tab1.ColumnWidths = "50 50 50";
            //Set default cell border using BorderInfo object
            tab1.DefaultCellBorder = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, 0.1F);
            //Set table border using another customized BorderInfo object
            tab1.Border = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, 1F);
            //Create MarginInfo object and set its left, bottom, right and top margins
            Aspose.Pdf.MarginInfo margin = new Aspose.Pdf.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.Row row1 = tab1.Rows.Add();
            row1.Cells.Add("col1");
            row1.Cells.Add("col2");
            row1.Cells.Add();
            TextFragment mytext = new TextFragment("col3 with large text string");

            //row1.Cells.Add("col3 with large text string to be placed inside cell");
            row1.Cells[2].Paragraphs.Add(mytext);
            row1.Cells[2].IsWordWrapped = false;
            //row1.Cells[2].Paragraphs[0].FixedWidth= 80;
            Aspose.Pdf.Row row2 = tab1.Rows.Add();
            row2.Cells.Add("item1");
            row2.Cells.Add("item2");
            row2.Cells.Add("item3");
            //Save the Pdf
            doc.Save(dataDir + "output.pdf");
        }
Exemple #11
0
        public static void Run()
        {
            // ExStart:RenderTable
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Tables();

            Document doc      = new Document();
            PageInfo pageInfo = doc.PageInfo;

            Aspose.Pdf.MarginInfo marginInfo = pageInfo.Margin;

            marginInfo.Left   = 37;
            marginInfo.Right  = 37;
            marginInfo.Top    = 37;
            marginInfo.Bottom = 37;

            pageInfo.IsLandscape = true;

            Aspose.Pdf.Table table = new Aspose.Pdf.Table();
            table.ColumnWidths = "50 100";
            // Added page.
            Page curPage = doc.Pages.Add();

            for (int i = 1; i <= 120; i++)
            {
                Aspose.Pdf.Row row = table.Rows.Add();
                row.FixedRowHeight = 15;
                Aspose.Pdf.Cell cell1 = row.Cells.Add();
                cell1.Paragraphs.Add(new TextFragment("Content 1"));
                Aspose.Pdf.Cell cell2 = row.Cells.Add();
                cell2.Paragraphs.Add(new TextFragment("HHHHH"));
            }
            Aspose.Pdf.Paragraphs paragraphs = curPage.Paragraphs;
            paragraphs.Add(table);
            /********************************************/
            Aspose.Pdf.Table table1 = new Aspose.Pdf.Table();
            table.ColumnWidths = "100 100";
            for (int i = 1; i <= 10; i++)
            {
                Aspose.Pdf.Row  row   = table1.Rows.Add();
                Aspose.Pdf.Cell cell1 = row.Cells.Add();
                cell1.Paragraphs.Add(new TextFragment("LAAAAAAA"));
                Aspose.Pdf.Cell cell2 = row.Cells.Add();
                cell2.Paragraphs.Add(new TextFragment("LAAGGGGGG"));
            }
            table1.IsInNewPage = true;
            // I want to keep table 1 to next page please...
            paragraphs.Add(table1);
            dataDir = dataDir + "IsNewPageProperty_Test_out.pdf";
            doc.Save(dataDir);
            // ExEnd:RenderTable
            Console.WriteLine("\nTable render successfully on a page.\nFile saved at " + dataDir);
        }
        public static void Run()
        {
            // ExStart:RenderTable
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Tables();

            Document doc = new Document();
            PageInfo pageInfo = doc.PageInfo;
            Aspose.Pdf.MarginInfo marginInfo = pageInfo.Margin;

            marginInfo.Left = 37;
            marginInfo.Right = 37;
            marginInfo.Top = 37;
            marginInfo.Bottom = 37;

            pageInfo.IsLandscape = true;

            Aspose.Pdf.Table table = new Aspose.Pdf.Table();
            table.ColumnWidths = "50 100";
            // Added page.
            Page curPage = doc.Pages.Add();
            for (int i = 1; i <= 120; i++)
            {
                Aspose.Pdf.Row row = table.Rows.Add();
                row.FixedRowHeight = 15;
                Aspose.Pdf.Cell cell1 = row.Cells.Add();
                cell1.Paragraphs.Add(new TextFragment("Content 1"));
                Aspose.Pdf.Cell cell2 = row.Cells.Add();
                cell2.Paragraphs.Add(new TextFragment("HHHHH"));
            }
            Aspose.Pdf.Paragraphs paragraphs = curPage.Paragraphs;
            paragraphs.Add(table);
            /********************************************/
            Aspose.Pdf.Table table1 = new Aspose.Pdf.Table();
            table.ColumnWidths = "100 100";
            for (int i = 1; i <= 10; i++)
            {
                Aspose.Pdf.Row row = table1.Rows.Add();
                Aspose.Pdf.Cell cell1 = row.Cells.Add();
                cell1.Paragraphs.Add(new TextFragment("LAAAAAAA"));
                Aspose.Pdf.Cell cell2 = row.Cells.Add();
                cell2.Paragraphs.Add(new TextFragment("LAAGGGGGG"));
            }
            table1.IsInNewPage = true;
            // I want to keep table 1 to next page please...
            paragraphs.Add(table1);
            dataDir = dataDir + "IsNewPageProperty_Test_out.pdf";
            doc.Save(dataDir);
            // ExEnd:RenderTable
            Console.WriteLine("\nTable render successfully on a page.\nFile saved at " + dataDir); 
            
            
        }
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Tables();

            // Create directory if it is not already present.
            bool IsExists = System.IO.Directory.Exists(dataDir);
            if (!IsExists)
                System.IO.Directory.CreateDirectory(dataDir);


            //Instntiate the Document object by calling its empty constructor
            Document doc = new Document();
            Page page = doc.Pages.Add();
            //Instantiate a table object
            Aspose.Pdf.Table tab1 = new Aspose.Pdf.Table();
            //Add the table in paragraphs collection of the desired section
            page.Paragraphs.Add(tab1);
            //Set with column widths of the table
            tab1.ColumnWidths = "50 50 50";
            //Set default cell border using BorderInfo object
            tab1.DefaultCellBorder = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, 0.1F);
            //Set table border using another customized BorderInfo object
            tab1.Border = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, 1F);
            //Create MarginInfo object and set its left, bottom, right and top margins
            Aspose.Pdf.MarginInfo margin = new Aspose.Pdf.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.Row row1 = tab1.Rows.Add();
            row1.Cells.Add("col1");
            row1.Cells.Add("col2");
            row1.Cells.Add();
            TextFragment mytext = new TextFragment("col3 with large text string");
            //row1.Cells.Add("col3 with large text string to be placed inside cell");
            row1.Cells[2].Paragraphs.Add(mytext);
            row1.Cells[2].IsWordWrapped = false;
            //row1.Cells[2].Paragraphs[0].FixedWidth= 80;
            Aspose.Pdf.Row row2 = tab1.Rows.Add();
            row2.Cells.Add("item1");
            row2.Cells.Add("item2");
            row2.Cells.Add("item3");
            //Save the Pdf
            doc.Save(dataDir+ "MarginsOrPadding_out.pdf");
            
            
        }
        public static void Run()
        {
            // ExStart:AutoFitToWindow
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Tables();

            // Instntiate the Pdf object by calling its empty constructor
            Document doc = new Document();
            // Create the section in the Pdf object
            Page sec1 = doc.Pages.Add();

            // Instantiate a table object
            Aspose.Pdf.Table tab1 = new Aspose.Pdf.Table();
            // Add the table in paragraphs collection of the desired section
            sec1.Paragraphs.Add(tab1);

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

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

            // Set table border using another customized BorderInfo object
            tab1.Border = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, 1F);
            // Create MarginInfo object and set its left, bottom, right and top margins
            Aspose.Pdf.MarginInfo margin = new Aspose.Pdf.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.Row row1 = tab1.Rows.Add();
            row1.Cells.Add("col1");
            row1.Cells.Add("col2");
            row1.Cells.Add("col3");
            Aspose.Pdf.Row row2 = tab1.Rows.Add();
            row2.Cells.Add("item1");
            row2.Cells.Add("item2");
            row2.Cells.Add("item3");

            dataDir = dataDir + "AutoFitToWindow_out.pdf";
            // Save updated document containing table object
            doc.Save(dataDir);
            // ExEnd:AutoFitToWindow
                      
        }
Exemple #15
0
        public static MemoryStream AddFooterAndWatermark(MemoryStream pdfStream, WatermarkArg arg)
        {
            var pdfDocument = new Aspose.Pdf.Document(pdfStream);
            var pdfLastPage = pdfDocument.Pages[pdfDocument.Pages.Count];
            var footer      = new Aspose.Pdf.HeaderFooter();

            //Instantiate a table object
            Aspose.Pdf.Table tab1 = new Aspose.Pdf.Table();
            tab1.HorizontalAlignment = HorizontalAlignment.Center;
            //設定預設的文字格式
            var defaultTextState = new TextState("MingLiU", 8);

            footer.Paragraphs.Add(tab1);
            tab1.DefaultColumnWidth   = "180";
            tab1.DefaultCellTextState = defaultTextState;
            //Create rows in the table and then cells in the rows
            var row1  = tab1.Rows.Add();
            var cellL = row1.Cells.Add("信用資訊查詢主管");

            //cellL.DefaultCellTextState = defaultTextState;
            cellL.Alignment = HorizontalAlignment.Left;
            var cellR = row1.Cells.Add("經辦");

            cellR.Alignment    = HorizontalAlignment.Right;
            pdfLastPage.Footer = footer;

            if (!string.IsNullOrWhiteSpace(arg.Watermark))
            {
                var text = new FormattedText(arg.Watermark);
                foreach (var page in pdfDocument.Pages)
                {
                    switch (arg.WMStyle)
                    {
                    case WatermarkStyle.FitPage:
                        AddWatermarkFitPage(page, arg);
                        break;

                    case WatermarkStyle.RepeatHorizontal:
                        AddWatermarkRepeatHorizontal(page, arg);
                        break;

                    default:
                        break;
                    }
                }
            }
            var newPdfStream = new MemoryStream();

            pdfDocument.Save(newPdfStream);
            return(newPdfStream);
        }
        public static void Run()
        {
            // ExStart:AutoFitToWindow
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Tables();

            // Instntiate the Pdf object by calling its empty constructor
            Document doc = new Document();
            // Create the section in the Pdf object
            Page sec1 = doc.Pages.Add();

            // Instantiate a table object
            Aspose.Pdf.Table tab1 = new Aspose.Pdf.Table();
            // Add the table in paragraphs collection of the desired section
            sec1.Paragraphs.Add(tab1);

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

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

            // Set table border using another customized BorderInfo object
            tab1.Border = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, 1F);
            // Create MarginInfo object and set its left, bottom, right and top margins
            Aspose.Pdf.MarginInfo margin = new Aspose.Pdf.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.Row row1 = tab1.Rows.Add();
            row1.Cells.Add("col1");
            row1.Cells.Add("col2");
            row1.Cells.Add("col3");
            Aspose.Pdf.Row row2 = tab1.Rows.Add();
            row2.Cells.Add("item1");
            row2.Cells.Add("item2");
            row2.Cells.Add("item3");

            dataDir = dataDir + "AutoFitToWindow_out.pdf";
            // Save updated document containing table object
            doc.Save(dataDir);
            // ExEnd:AutoFitToWindow
        }
Exemple #17
0
        public static void Run()
        {
            // ExStart:MarginsOrPadding
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Tables();

            // Instntiate the Document object by calling its empty constructor
            Document doc  = new Document();
            Page     page = doc.Pages.Add();

            // Instantiate a table object
            Aspose.Pdf.Table tab1 = new Aspose.Pdf.Table();
            // Add the table in paragraphs collection of the desired section
            page.Paragraphs.Add(tab1);
            // Set with column widths of the table
            tab1.ColumnWidths = "50 50 50";
            // Set default cell border using BorderInfo object
            tab1.DefaultCellBorder = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, 0.1F);
            // Set table border using another customized BorderInfo object
            tab1.Border = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, 1F);
            // Create MarginInfo object and set its left, bottom, right and top margins
            Aspose.Pdf.MarginInfo margin = new Aspose.Pdf.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.Row row1 = tab1.Rows.Add();
            row1.Cells.Add("col1");
            row1.Cells.Add("col2");
            row1.Cells.Add();
            TextFragment mytext = new TextFragment("col3 with large text string");

            // Row1.Cells.Add("col3 with large text string to be placed inside cell");
            row1.Cells[2].Paragraphs.Add(mytext);
            row1.Cells[2].IsWordWrapped = false;
            // Row1.Cells[2].Paragraphs[0].FixedWidth= 80;
            Aspose.Pdf.Row row2 = tab1.Rows.Add();
            row2.Cells.Add("item1");
            row2.Cells.Add("item2");
            row2.Cells.Add("item3");
            dataDir = dataDir + "MarginsOrPadding_out_.pdf";
            // Save the Pdf
            doc.Save(dataDir);
            // ExEnd:MarginsOrPadding
            Console.WriteLine("\nCell and table border width setup successfully.\nFile saved at " + dataDir);
        }
Exemple #18
0
        public static void Run()
        {
            // ExStart:IntegrateWithDatabase
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_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);
            // Create Document instance
            Document doc = new Document();

            doc.Pages.Add();
            // Initializes a new instance of the Table
            Aspose.Pdf.Table table = new Aspose.Pdf.Table();
            // Set column widths of the table
            table.ColumnWidths = "40 100 100 100";
            // Set the table border color as LightGray
            table.Border = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, .5f, Aspose.Pdf.Color.FromRgb(System.Drawing.Color.LightGray));
            // Set the border for table cells
            table.DefaultCellBorder = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, .5f, Aspose.Pdf.Color.FromRgb(System.Drawing.Color.LightGray));
            table.ImportDataTable(dt, true, 0, 1, 3, 3);

            // Add table object to first page of input document
            doc.Pages[1].Paragraphs.Add(table);
            dataDir = dataDir + "DataIntegrated_out.pdf";
            // Save updated document containing table object
            doc.Save(dataDir);
            // ExEnd:IntegrateWithDatabase
            Console.WriteLine("\nDatabase integrated successfully.\nFile saved at " + dataDir);
        }
        public static void Run()
        {
            // ExStart:AddSVGObject
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Tables();

            // Instantiate Document object
            Document doc = new Document();

            // Create an image instance
            Aspose.Pdf.Image img = new Aspose.Pdf.Image();
            // Set image type as SVG
            img.FileType = Aspose.Pdf.ImageFileType.Svg;
            // Path for source file
            img.File = dataDir + "SVGToPDF.svg";
            // Set width for image instance
            img.FixWidth = 50;
            // Set height for image instance
            img.FixHeight = 50;
            // Create table instance
            Aspose.Pdf.Table table = new Aspose.Pdf.Table();
            // Set width for table cells
            table.ColumnWidths = "100 100";
            // Create row object and add it to table instance
            Aspose.Pdf.Row row = table.Rows.Add();
            // Create cell object and add it to row instance
            Aspose.Pdf.Cell cell = row.Cells.Add();
            // Add textfragment to paragraphs collection of cell object
            cell.Paragraphs.Add(new TextFragment("First cell"));
            // Add another cell to row object
            cell = row.Cells.Add();
            // Add SVG image to paragraphs collection of recently added cell instance
            cell.Paragraphs.Add(img);
            // Create page object and add it to pages collection of document instance
            Page page = doc.Pages.Add();

            // Add table to paragraphs collection of page object
            page.Paragraphs.Add(table);

            dataDir = dataDir + "AddSVGObject_out_.pdf";
            // Save PDF file
            doc.Save(dataDir);
            // ExEnd:AddSVGObject
            Console.WriteLine("\nSVG image added successfully inside a table cell.\nFile saved at " + dataDir);
        }
        public static void Main(string[] args)
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");

            /* Create a DataTable object (Employee) and add columns to it (Employee_ID,
             * Employee_Name, Gender).
             */
            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);
            // Create Document instance
            Document doc = new Document();

            doc.Pages.Add();
            // Initializes a new instance of the Table
            Aspose.Pdf.Table table = new Aspose.Pdf.Table();
            //Set column widths of the table
            table.ColumnWidths = "40 100 100 100";
            // Set the table border color as LightGray
            table.Border = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, .5f, Aspose.Pdf.Color.FromRgb(System.Drawing.Color.LightGray));
            // set the border for table cells
            table.DefaultCellBorder = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, .5f, Aspose.Pdf.Color.FromRgb(System.Drawing.Color.LightGray));
            table.ImportDataTable(dt, true, 0, 1, 3, 3);

            // Add table object to first page of input document
            doc.Pages[1].Paragraphs.Add(table);
            // Save updated document containing table object
            doc.Save(dataDir + "DataIntegrated.pdf");
        }
        public static void Run()
        {
            // ExStart:InsertPageBreak
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Tables();

            // Instantiate Document instance
            Document doc = new Document();

            // Add page to pages collection of PDF file
            doc.Pages.Add();
            // Create table instance
            Aspose.Pdf.Table tab = new Aspose.Pdf.Table();
            // Set border style for table
            tab.Border = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, Aspose.Pdf.Color.Red);
            // Set default border style for table with border color as Red
            tab.DefaultCellBorder = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, Aspose.Pdf.Color.Red);
            // Specify table columsn widht
            tab.ColumnWidths = "100 100";
            // Create a loop to add 200 rows for table
            for (int counter = 0; counter <= 200; counter++)
            {
                Aspose.Pdf.Row row = new Aspose.Pdf.Row();
                tab.Rows.Add(row);
                Aspose.Pdf.Cell cell1 = new Aspose.Pdf.Cell();
                cell1.Paragraphs.Add(new TextFragment("Cell " + counter + ", 0"));
                row.Cells.Add(cell1); Aspose.Pdf.Cell cell2 = new Aspose.Pdf.Cell();
                cell2.Paragraphs.Add(new TextFragment("Cell " + counter + ", 1"));
                row.Cells.Add(cell2);
                // When 10 rows are added, render new row in new page
                if (counter % 10 == 0 && counter != 0)
                {
                    row.IsInNewPage = true;
                }
            }
            // Add table to paragraphs collection of PDF file
            doc.Pages[1].Paragraphs.Add(tab);

            dataDir = dataDir + "InsertPageBreak_out_.pdf";
            // Save the PDF document
            doc.Save(dataDir);
            // ExEnd:InsertPageBreak
            Console.WriteLine("\nPage break inserted successfully.\nFile saved at " + dataDir);
        }
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Tables();

            /* Create a DataTable object (Employee) and add columns to it (Employee_ID, 
  * Employee_Name, Gender).   
  */
            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);
            // Create Document instance
            Document doc = new Document();
            doc.Pages.Add();
            // Initializes a new instance of the Table
            Aspose.Pdf.Table table = new Aspose.Pdf.Table();
            //Set column widths of the table
            table.ColumnWidths = "40 100 100 100";
            // Set the table border color as LightGray
            table.Border = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, .5f, Aspose.Pdf.Color.FromRgb(System.Drawing.Color.LightGray));
            // set the border for table cells
            table.DefaultCellBorder = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, .5f, Aspose.Pdf.Color.FromRgb(System.Drawing.Color.LightGray));
            table.ImportDataTable(dt, true, 0, 1, 3, 3);

            // Add table object to first page of input document
            doc.Pages[1].Paragraphs.Add(table);
            // Save updated document containing table object
            doc.Save(dataDir+ "DataIntegrated.pdf");
            
            
        }
        public static void Run()
        {
            // ExStart:AddSVGObject
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Tables();

            // Instantiate Document object
            Document doc = new Document();
            // Create an image instance
            Aspose.Pdf.Image img = new Aspose.Pdf.Image();
            // Set image type as SVG
            img.FileType = Aspose.Pdf.ImageFileType.Svg;
            // Path for source file
            img.File = dataDir + "SVGToPDF.svg";
            // Set width for image instance
            img.FixWidth = 50;
            // Set height for image instance
            img.FixHeight = 50;
            // Create table instance
            Aspose.Pdf.Table table = new Aspose.Pdf.Table();
            // Set width for table cells
            table.ColumnWidths = "100 100";
            // Create row object and add it to table instance
            Aspose.Pdf.Row row = table.Rows.Add();
            // Create cell object and add it to row instance
            Aspose.Pdf.Cell cell = row.Cells.Add();
            // Add textfragment to paragraphs collection of cell object
            cell.Paragraphs.Add(new TextFragment("First cell"));
            // Add another cell to row object
            cell = row.Cells.Add();
            // Add SVG image to paragraphs collection of recently added cell instance
            cell.Paragraphs.Add(img);
            // Create page object and add it to pages collection of document instance
            Page page = doc.Pages.Add();
            // Add table to paragraphs collection of page object
            page.Paragraphs.Add(table);

            dataDir = dataDir + "AddSVGObject_out.pdf";
            // Save PDF file
            doc.Save(dataDir);
            // ExEnd:AddSVGObject
            Console.WriteLine("\nSVG image added successfully inside a table cell.\nFile saved at " + dataDir);            
        }
        public static void Run()
        {
            // ExStart:RoundedCornerTable
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Tables();
            Aspose.Pdf.Table tab1 = new Aspose.Pdf.Table();

            GraphInfo graph = new GraphInfo();
            graph.Color = Aspose.Pdf.Color.Red;
            // Create a blank BorderInfo object
            BorderInfo bInfo = new BorderInfo(BorderSide.All, graph);
            // Set the border a rounder border where radius of round is 15
            bInfo.RoundedBorderRadius = 15;
            // Set the table Corner style as Round.
            tab1.CornerStyle = Aspose.Pdf.BorderCornerStyle.Round;
            // Set the table border information
            tab1.Border = bInfo;
            // ExEnd:RoundedCornerTable
                     
        }
        public static void Run()
        {
            // ExStart:InsertPageBreak
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Tables();

            // Instantiate Document instance
            Document doc = new Document();
            // Add page to pages collection of PDF file
            doc.Pages.Add();
            // Create table instance
            Aspose.Pdf.Table tab = new Aspose.Pdf.Table();
            // Set border style for table
            tab.Border = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, Aspose.Pdf.Color.Red);
            // Set default border style for table with border color as Red
            tab.DefaultCellBorder = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, Aspose.Pdf.Color.Red);
            // Specify table columsn widht
            tab.ColumnWidths = "100 100";
            // Create a loop to add 200 rows for table
            for (int counter = 0; counter <= 200; counter++)
            {
                Aspose.Pdf.Row row = new Aspose.Pdf.Row();
                tab.Rows.Add(row);
                Aspose.Pdf.Cell cell1 = new Aspose.Pdf.Cell();
                cell1.Paragraphs.Add(new TextFragment("Cell " + counter + ", 0"));
                row.Cells.Add(cell1); Aspose.Pdf.Cell cell2 = new Aspose.Pdf.Cell();
                cell2.Paragraphs.Add(new TextFragment("Cell " + counter + ", 1"));
                row.Cells.Add(cell2);
                // When 10 rows are added, render new row in new page
                if (counter % 10 == 0 && counter != 0) row.IsInNewPage = true;
            }
            // Add table to paragraphs collection of PDF file
            doc.Pages[1].Paragraphs.Add(tab);

            dataDir = dataDir + "InsertPageBreak_out.pdf";
            // Save the PDF document
            doc.Save(dataDir);
            // ExEnd:InsertPageBreak
            Console.WriteLine("\nPage break inserted successfully.\nFile saved at " + dataDir);
            
        }
Exemple #26
0
        public static void Main(string[] args)
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");
            // Create directory if it is not already present.
            bool IsExists = System.IO.Directory.Exists(dataDir);

            if (!IsExists)
            {
                System.IO.Directory.CreateDirectory(dataDir);
            }


            // instantiate Document object
            Document doc = new Document();
            // add page to PDF document
            Page page = doc.Pages.Add();

            // create BorderInfo object
            Aspose.Pdf.BorderInfo border = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All);
            // specify that Top border will be double
            border.Top.IsDoubled = true;
            // specify that bottom border will be double
            border.Bottom.IsDoubled = true;
            // instantiate Table object
            Aspose.Pdf.Table table = new Aspose.Pdf.Table();
            // specify Columns width information
            table.ColumnWidths = "100";
            // create Row object
            Aspose.Pdf.Row row = table.Rows.Add();
            // add a Table cell to cells collection of row
            Aspose.Pdf.Cell cell = row.Cells.Add("some text");
            // set the border for cell object (double border)
            cell.Border = border;
            // add table to paragraphs collection of Page
            page.Paragraphs.Add(table);
            // save the PDF document
            doc.Save(dataDir + "TableBorderTest.pdf");
        }
Exemple #27
0
        public static void Run()
        {
            // ExStart:RoundedCornerTable
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Tables();

            Aspose.Pdf.Table tab1 = new Aspose.Pdf.Table();

            GraphInfo graph = new GraphInfo();

            graph.Color = Aspose.Pdf.Color.Red;
            // Create a blank BorderInfo object
            BorderInfo bInfo = new BorderInfo(BorderSide.All, graph);

            // Set the border a rounder border where radius of round is 15
            bInfo.RoundedBorderRadius = 15;
            // Set the table Corner style as Round.
            tab1.CornerStyle = Aspose.Pdf.BorderCornerStyle.Round;
            // Set the table border information
            tab1.Border = bInfo;
            // ExEnd:RoundedCornerTable
        }
Exemple #28
0
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Tables();
            // Create directory if it is not already present.
            bool IsExists = System.IO.Directory.Exists(dataDir);
            if (!IsExists)
                System.IO.Directory.CreateDirectory(dataDir);


            // instantiate Document object
            Document doc = new Document();
            // add page to PDF document
            Page page = doc.Pages.Add();
            // create BorderInfo object
            Aspose.Pdf.BorderInfo border = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All);
            // specify that Top border will be double
            border.Top.IsDoubled = true;
            // specify that bottom border will be double
            border.Bottom.IsDoubled = true;
            // instantiate Table object
            Aspose.Pdf.Table table = new Aspose.Pdf.Table();
            // specify Columns width information
            table.ColumnWidths = "100";
            // create Row object
            Aspose.Pdf.Row row = table.Rows.Add();
            // add a Table cell to cells collection of row
            Aspose.Pdf.Cell cell = row.Cells.Add("some text");
            // set the border for cell object (double border)
            cell.Border = border;
            // add table to paragraphs collection of Page
            page.Paragraphs.Add(table);
            // save the PDF document
            doc.Save(dataDir+ "TableBorderTest.pdf");
            
            
        }
        public static void Run()
        {
            try
            {
                // ExStart:RadioButtonWithOptions
                // The path to the documents directory.
                string dataDir = RunExamples.GetDataDir_AsposePdf_Forms();

                Document doc = new Document();
                Page page = doc.Pages.Add();
                Aspose.Pdf.Table table = new Aspose.Pdf.Table();
                table.ColumnWidths = "120 120 120";
                page.Paragraphs.Add(table);
                Row r1 = table.Rows.Add();
                Cell c1 = r1.Cells.Add();
                Cell c2 = r1.Cells.Add();
                Cell c3 = r1.Cells.Add();

                RadioButtonField rf = new RadioButtonField(page);
                rf.PartialName = "radio";
                doc.Form.Add(rf, 1);

                RadioButtonOptionField opt1 = new RadioButtonOptionField();
                RadioButtonOptionField opt2 = new RadioButtonOptionField();
                RadioButtonOptionField opt3 = new RadioButtonOptionField();

                opt1.OptionName = "Item1";
                opt2.OptionName = "Item2";
                opt3.OptionName = "Item3";

                opt1.Width = 15;
                opt1.Height = 15;
                opt2.Width = 15;
                opt2.Height = 15;
                opt3.Width = 15;
                opt3.Height = 15;

                rf.Add(opt1);
                rf.Add(opt2);
                rf.Add(opt3);

                opt1.Border = new Border(opt1);
                opt1.Border.Width = 1;
                opt1.Border.Style = BorderStyle.Solid;
                opt1.Characteristics.Border = System.Drawing.Color.Black;
                opt1.DefaultAppearance.TextColor = System.Drawing.Color.Red;
                opt1.Caption = new TextFragment("Item1");
                opt2.Border = new Border(opt1);
                opt2.Border.Width = 1;
                opt2.Border.Style = BorderStyle.Solid;
                opt2.Characteristics.Border = System.Drawing.Color.Black;
                opt2.DefaultAppearance.TextColor = System.Drawing.Color.Red;
                opt2.Caption = new TextFragment("Item2");
                opt3.Border = new Border(opt1);
                opt3.Border.Width = 1;
                opt3.Border.Style = BorderStyle.Solid;
                opt3.Characteristics.Border = System.Drawing.Color.Black;
                opt3.DefaultAppearance.TextColor = System.Drawing.Color.Red;
                opt3.Caption = new TextFragment("Item3");
                c1.Paragraphs.Add(opt1);
                c2.Paragraphs.Add(opt2);
                c3.Paragraphs.Add(opt3);

                dataDir = dataDir + "RadioButtonWithOptions_out.pdf";
                // Save the PDF file
                doc.Save(dataDir);
                // ExEnd:RadioButtonWithOptions
                Console.WriteLine("\nRadio button field with three options added successfully.\nFile saved at " + dataDir);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

        }
        public static void AddImageAndTable()
        {
            // ExStart:AddImageAndTable
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Text();
            
            Document doc = new Document();
            Page page = doc.Pages.Add();
            TextFragment text = new TextFragment("some text");
            page.Paragraphs.Add(text);

            text.FootNote = new Note();
            Aspose.Pdf.Image image = new Aspose.Pdf.Image();
            image.File = dataDir + "aspose-logo.jpg";
            image.FixHeight = 20;
            text.FootNote.Paragraphs.Add(image);
            TextFragment footNote = new TextFragment("footnote text");
            footNote.TextState.FontSize = 20;
            footNote.IsInLineParagraph = true;
            text.FootNote.Paragraphs.Add(footNote);
            Aspose.Pdf.Table table = new Aspose.Pdf.Table();
            table.Rows.Add().Cells.Add().Paragraphs.Add(new TextFragment("Row 1 Cell 1"));
            text.FootNote.Paragraphs.Add(table);

            dataDir = dataDir + "AddImageAndTable_out.pdf";

            // Save resulting PDF document.
            doc.Save(dataDir);
            // ExEnd:AddImageAndTable
            Console.WriteLine("\nTable and image added successfully to FootNote.\nFile saved at " + dataDir);
        }
Exemple #31
0
        public static void Run()
        {
            // ExStart:DetermineTableBreak
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Tables();

            // Instantiate an object PDF class
            Document pdf = new Document();

            // Add the section to PDF document sections collection
            Aspose.Pdf.Page page = pdf.Pages.Add();
            // Instantiate a table object
            Aspose.Pdf.Table table1 = new Aspose.Pdf.Table();
            table1.Margin.Top = 300;
            // Add the table in paragraphs collection of the desired section
            page.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.BorderInfo(Aspose.Pdf.BorderSide.All, 0.1F);
            // Set table border using another customized BorderInfo object
            table1.Border = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, 1F);
            // Create MarginInfo object and set its left, bottom, right and top margins
            Aspose.Pdf.MarginInfo margin = new Aspose.Pdf.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.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 = (float)pdf.PageInfo.Height;
            // Get the total height information of Page Top & Bottom margin,
            // Table Top margin and table height.
            float TotalObjectsHeight = (float)page.PageInfo.Margin.Top + (float)page.PageInfo.Margin.Bottom + (float)table1.Margin.Top + (float)table1.GetHeight();

            // Display Page Height, Table Height, table Top margin and Page Top
            // And Bottom margin information
            Console.WriteLine("PDF document Height = " + pdf.PageInfo.Height.ToString() + "\nTop Margin Info = " + page.PageInfo.Margin.Top.ToString() + "\nBottom Margin Info = " + page.PageInfo.Margin.Bottom.ToString() + "\n\nTable-Top Margin Info = " + table1.Margin.Top.ToString() + "\nAverage Row Height = " + table1.Rows[0].MinRowHeight.ToString() + " \nTable height " + table1.GetHeight().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");
            }


            dataDir = dataDir + "DetermineTableBreak_out.pdf";
            // Save the pdf document
            pdf.Save(dataDir);
            // ExEnd:DetermineTableBreak
            Console.WriteLine("\nTable break determined successfully.\nFile saved at " + dataDir);
        }
Exemple #32
0
        public bool MakeReport(List <Tour> tours)
        {
            try
            {
                double total_tours = 0;
                double total_logs  = 0;

                double total_needed_time = 0;
                double total_distance    = 0;

                int has_tunnels    = 0;
                int has_no_tunnels = 0;

                int has_highway    = 0;
                int has_no_highway = 0;

                int has_bridge    = 0;
                int has_no_bridge = 0;

                int has_access_restriction = 0;
                int has_no_restriction     = 0;


                foreach (Tour t in tours)
                {
                    total_tours += 1;

                    //die logs der tour zum totalen hinzufügen
                    if (t.LogItems != null)
                    {
                        foreach (Log l in t.LogItems)
                        {
                            total_logs += 1;
                        }
                    }



                    //die zeit aus der db splitten um sekunden,minuten,stunden und tage zu erhalten
                    string[] time = t.TourInfo.Time.Split(':');

                    double secondes = Convert.ToDouble(time[3]);

                    double minutes = Convert.ToDouble(time[2]);

                    double hours = Convert.ToDouble(time[1]);

                    double days = Convert.ToDouble(time[0]);

                    //die angegebene zeit in sekunden umrechnen
                    double total_seconds = secondes + minutes * 60;
                    total_seconds += hours * 60 * 60;
                    total_seconds += days * 24 * 60 * 60;


                    // die sekunden in stunden umberechnen
                    double needed_time = total_seconds / 60 / 60;

                    //auf das totale dazu addieren
                    total_needed_time += needed_time;

                    //distanz jeder tour auf die totale dazu addieren
                    string distance = t.TourInfo.Distance.Replace("km", "");

                    total_distance = Convert.ToDouble(distance);

                    //Has tunnels
                    if (t.TourInfo.HasTunnels)
                    {
                        has_tunnels += 1;
                    }
                    else
                    {
                        has_no_tunnels += 1;
                    }

                    //Has Highway
                    if (t.TourInfo.HasHighways)
                    {
                        has_highway += 1;
                    }
                    else
                    {
                        has_no_highway += 1;
                    }

                    //Has Bridge
                    if (t.TourInfo.HasBridge)
                    {
                        has_bridge += 1;
                    }
                    else
                    {
                        has_no_bridge += 1;
                    }

                    //Has Acces Restriction
                    if (t.TourInfo.HasAccesRestriction)
                    {
                        has_access_restriction += 1;
                    }
                    else
                    {
                        has_no_restriction += 1;
                    }
                }

                //PDF generator
                Aspose.Pdf.Document document = new Aspose.Pdf.Document();

                Aspose.Pdf.Page page = document.Pages.Add();

                // Add Header
                var header = new TextFragment("Tours Summary");
                header.TextState.Font      = FontRepository.FindFont("Arial");
                header.TextState.FontSize  = 24;
                header.HorizontalAlignment = HorizontalAlignment.Center;
                header.Position            = new Position(130, 720);
                page.Paragraphs.Add(header);

                // Add description
                var descriptionText = "This document serves to provide a rough overview of a total of important information of the tours";
                var description     = new TextFragment(descriptionText);
                description.TextState.Font      = FontRepository.FindFont("Times New Roman");
                description.TextState.FontSize  = 14;
                description.HorizontalAlignment = HorizontalAlignment.Center;
                page.Paragraphs.Add(description);


                //Labels of the information
                var info_text = "\n__________________________________________________________________________________________________________________________________________\n\n" +
                                "Total number of Tours is " + total_tours + "\nTotal number of Logs is " + total_logs
                                + "\nThe total distance covered is " + total_distance + " km\nThe total past time is " + total_needed_time +
                                " hours\n\n";
                var info = new TextFragment(info_text);
                info.TextState.Font            = FontRepository.FindFont("Times New Roman");
                info.TextState.FontSize        = 12;
                info.HorizontalAlignment       = HorizontalAlignment.Left;
                info.TextState.ForegroundColor = Aspose.Pdf.Color.Black;
                page.Paragraphs.Add(info);


                //Tabelle erstellen
                var table = new Aspose.Pdf.Table
                {
                    ColumnWidths       = "100",
                    Border             = new BorderInfo(BorderSide.Box, 1f, Aspose.Pdf.Color.DarkSlateGray),
                    DefaultCellBorder  = new BorderInfo(BorderSide.Box, 0.5f, Aspose.Pdf.Color.Black),
                    DefaultCellPadding = new MarginInfo(4.5, 4.5, 4.5, 4.5),
                    Margin             =
                    {
                        Bottom = 10
                    },
                    DefaultCellTextState =
                    {
                        Font = FontRepository.FindFont("Helvetica")
                    }
                };

                var headerRow = table.Rows.Add();
                headerRow.Cells.Add("");
                headerRow.Cells.Add("Yes");
                headerRow.Cells.Add("No");


                foreach (Aspose.Pdf.Cell headerRowCell in headerRow.Cells)
                {
                    headerRowCell.BackgroundColor = Aspose.Pdf.Color.Gray;
                    headerRowCell.DefaultCellTextState.ForegroundColor = Aspose.Pdf.Color.WhiteSmoke;
                }



                var dataRow = table.Rows.Add();
                dataRow.Cells.Add("Has Tunnels");
                dataRow.Cells.Add(Convert.ToString(has_tunnels));
                dataRow.Cells.Add(Convert.ToString(has_no_tunnels));

                var dataRow2 = table.Rows.Add();
                dataRow2.Cells.Add("Has Highways");
                dataRow2.Cells.Add(Convert.ToString(has_highway));
                dataRow2.Cells.Add(Convert.ToString(has_no_highway));

                var dataRow3 = table.Rows.Add();
                dataRow3.Cells.Add("Has Bridge");
                dataRow3.Cells.Add(Convert.ToString(has_bridge));
                dataRow3.Cells.Add(Convert.ToString(has_no_bridge));

                var dataRow4 = table.Rows.Add();
                dataRow4.Cells.Add("Has Access restriction");
                dataRow4.Cells.Add(Convert.ToString(has_access_restriction));
                dataRow4.Cells.Add(Convert.ToString(has_no_restriction));


                page.Paragraphs.Add(table);

                document.Save(this.to_pdf + "Summary.pdf");

                return(true);
            }
            catch (Exception e)
            {
                string exception = "{\"errorMessages\":[\"" + e.Message.ToString() + "\"],\"errors\":{}}";
                log.Error(exception, e);
                return(false);
            }
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {

                //Creating new document
                Document doc = new Document();
                //add a new page in the document...
                Aspose.Pdf.Page page = doc.Pages.Add();

                //add header and footer in the document
                AddHeaderFooter(doc, "Online Application Form - Dated: " + DateTime.Now.Date.ToString("MM-dd-yyyy"), "");

                //crearing new table
                Aspose.Pdf.Table table = new Aspose.Pdf.Table();
                page.Paragraphs.Add(table);
                table.Alignment = Aspose.Pdf.HorizontalAlignment.Center;
                table.DefaultColumnWidth = "500";
                //create a new row in the table...
                Aspose.Pdf.Row row = new Aspose.Pdf.Row();
                table.Rows.Add(row);
                //create a new cell in the row...
                Aspose.Pdf.Cell cell = new Aspose.Pdf.Cell();
                row.Cells.Add(cell);

                cell.Alignment = Aspose.Pdf.HorizontalAlignment.Center;

                //create main heading of the page
                TextFragment txtFragmanet = new TextFragment("Online Application Form");

                txtFragmanet.TextState.FontSize = 15;
                txtFragmanet.TextState.FontStyle = FontStyles.Bold;
                cell.Paragraphs.Add(txtFragmanet);

                //============================ Section of personal information Starts======================
                // Add a new heading ...
                AddHeading(page, "Applied for Position: " + txtPosition.Text, 8, false);

                // Add a new heading ...
                AddHeading(page, "Personal Information:", 10, true);

                // create table for personal information
                Aspose.Pdf.Table tblPersonalInfo = new Aspose.Pdf.Table();
                page.Paragraphs.Add(tblPersonalInfo);
                tblPersonalInfo.DefaultCellTextState.FontSize = 6;
                //set columns width...
                tblPersonalInfo.ColumnWidths = "100 400";

                //adding personal details ...
                AddRow(tblPersonalInfo, "Name:", txtName.Text);
                AddRow(tblPersonalInfo, "Date of Birth:", txtDOB.Text);
                AddRow(tblPersonalInfo, "Email:", txtEmail.Text);
                AddRow(tblPersonalInfo, "Phone:", txtPhone.Text);
                AddRow(tblPersonalInfo, "Address:", txtAddress.Text);
                foreach (Aspose.Pdf.Row rw in tblPersonalInfo.Rows)
                {
                    rw.MinRowHeight = 20;
                }
                //=========================== End of Personal Information Section ================================================
                //=========================== Skills Starts ===============================================================
                //add new heading...
                AddHeading(page, "Skills:", 10, true);
                // add text fragment...
                TextFragment txtFragSkills = new TextFragment();
                txtFragSkills.TextState.Font = FontRepository.FindFont("Calibri");
                txtFragSkills.TextState.FontSize = 8;
                txtFragSkills.Text = txtSkills.Text;
                txtFragSkills.TextState.LineSpacing = 5;
                //add text fragment in pagae paragraph...
                page.Paragraphs.Add(txtFragSkills);

                //=========================== End of Objective Statement Section ====================================================
                //============================ Section of Educational information Starts======================
                // Add a new heading ...
                AddHeading(page, "Educational Details:", 10, true);

                //create datatable...
                DataTable dtEducationalDetails = new DataTable();
                dtEducationalDetails.Columns.Add("Degree", typeof(string));
                dtEducationalDetails.Columns.Add("Total Marks/GPA", typeof(string));
                dtEducationalDetails.Columns.Add("Obtained Marks/CGPA", typeof(string));
                dtEducationalDetails.Columns.Add("Institute", typeof(string));

                //get data from the gridview and store in datatable...
                foreach (GridViewRow grow in gvEducationalDetails.Rows)
                {

                    TextBox txtDegree = grow.FindControl("txtDegree") as TextBox;
                    TextBox txtTotalMarks = grow.FindControl("txtTotalMarks") as TextBox;
                    TextBox txtObtainedMarks = grow.FindControl("txtObtainedMarks") as TextBox;
                    TextBox txtInstitute = grow.FindControl("txtInstitute") as TextBox;
                    if (txtDegree.Text.Trim() != "" && txtTotalMarks.Text.Trim() != "" && txtObtainedMarks.Text.Trim() != "" && txtInstitute.Text.Trim() != "")
                    {
                        DataRow drow = dtEducationalDetails.NewRow();
                        drow[0] = txtDegree.Text;
                        drow[1] = txtTotalMarks.Text;
                        drow[2] = txtObtainedMarks.Text;
                        drow[3] = txtInstitute.Text;
                        dtEducationalDetails.Rows.Add(drow);
                    }
                }

                //create table for personal information
                Aspose.Pdf.Table tblEducationalInfo = new Aspose.Pdf.Table();

                tblEducationalInfo.ColumnWidths = "100 100 100 100";
                //add table to the dataset
                DataSet ds = new DataSet();
                ds.Tables.Add(dtEducationalDetails);

                tblEducationalInfo.DefaultCellTextState.FontSize = 8;
                tblEducationalInfo.DefaultCellTextState.Font = FontRepository.FindFont("Calibri");

                //Set the border style of the table...
                tblEducationalInfo.Border = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, .5f, Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Black));
                // Set default cell border...
                tblEducationalInfo.DefaultCellBorder = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, .5f, Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Black));
                // Set data source of the table...
                tblEducationalInfo.ImportDataTable(ds.Tables[0], true, 0, 0, ds.Tables[0].Rows.Count, 4);
                //Add table in paragraph...
                page.Paragraphs.Add(tblEducationalInfo);
                // Set the style of head row of the table...
                tblEducationalInfo.Rows[0].DefaultCellTextState.FontStyle = FontStyles.Bold;
                tblEducationalInfo.Rows[0].BackgroundColor = Aspose.Pdf.Color.LightGray;
                //set the min height of the rows...
                foreach (Aspose.Pdf.Row rw in tblEducationalInfo.Rows)
                {
                    rw.Cells[3].IsWordWrapped = false;
                    rw.MinRowHeight = 15;
                }
                //=========================== End of Educational Information Section ================================================

                //============================ Section of Professional Experience Starts======================
                // Add a new heading ...
                AddHeading(page, "Employment History:", 10, true);

                //create a new datatbale to store the data...
                DataTable dtExperience = new DataTable();
                dtExperience.Columns.Add("Designation", typeof(string));
                dtExperience.Columns.Add("Duration", typeof(string));
                dtExperience.Columns.Add("Organization", typeof(string));

                // get the data from the grid view into datatable...
                foreach (GridViewRow grow in gvExperience.Rows)
                {

                    TextBox txtDesignation = grow.FindControl("txtDesignation") as TextBox;
                    TextBox txtDuration = grow.FindControl("txtDuration") as TextBox;
                    TextBox txtOrganization = grow.FindControl("txtOrganization") as TextBox;
                    if (txtDesignation.Text.Trim() != "" && txtDuration.Text.Trim() != "" && txtOrganization.Text.Trim() != "")
                    {
                        DataRow drow = dtExperience.NewRow();
                        drow[0] = txtDesignation.Text;
                        drow[1] = txtDuration.Text;
                        drow[2] = txtOrganization.Text;

                        dtExperience.Rows.Add(drow);
                    }
                }

                //create table for personal information
                Aspose.Pdf.Table tblExperience = new Aspose.Pdf.Table();

               //set width of the columns...
                tblExperience.ColumnWidths = "100 100 200";
                //add table to the dataset
                ds = new DataSet();
                ds.Tables.Add(dtExperience);

                //set the font properties...
                tblExperience.DefaultCellTextState.FontSize = 8;
                tblExperience.DefaultCellTextState.Font = FontRepository.FindFont("Calibri");
                //Set the border style of the table...
                tblExperience.Border = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, .5f, Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Black));
                // Set default cell border...
                tblExperience.DefaultCellBorder = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, .5f, Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Black));
                // Set data source of the table...
                tblExperience.ImportDataTable(ds.Tables[0], true, 0, 0, ds.Tables[0].Rows.Count, 3);
                //Add table in paragraph...
                page.Paragraphs.Add(tblExperience);
                // Set the style of head row of the table...
                tblExperience.Rows[0].DefaultCellTextState.FontStyle = FontStyles.Bold;
                tblExperience.Rows[0].BackgroundColor = Aspose.Pdf.Color.LightGray;
                foreach (Aspose.Pdf.Row rw in tblExperience.Rows)
                {
                    rw.Cells[2].IsWordWrapped = false;
                    rw.MinRowHeight = 15;
                }
                //=========================== End of Professional Experience Section ================================================

                //=========================== Cover Letter Starts ===============================================================
                AddHeading(page, "Cover Letter:", 10, true);
                TextFragment txtFragCoverLetter = new TextFragment();
                txtFragCoverLetter.TextState.Font = FontRepository.FindFont("Calibri");
                txtFragCoverLetter.TextState.FontSize = 8;
                txtFragCoverLetter.Text = txtCoverLetter.Text;
                txtFragCoverLetter.TextState.LineSpacing = 5;
                page.Paragraphs.Add(txtFragCoverLetter);

                //=========================== End of Cover Letter Section ====================================================

                //Add watermark in the document...
                foreach (Aspose.Pdf.Page pg in doc.Pages)
                {
                    AddWaterMark(pg);
                }

                string path = Server.MapPath("~/Uploads/Application_" + DateTime.Now.ToString("dd_MM_yy HH_mm_ss") + ".pdf");
                doc.Save(path);
                msg.Text = "<div class='alert alert-success'><button data-dismiss='alert' class='close' type='button'>×</button>Your application has been submitted successfully.</div>";
                //show message "Your application has been submitted successfully."

            }
            catch(Exception exp)
            {
                msg.Text = "<div class='alert alert-danger'><button data-dismiss='alert' class='close' type='button'>×</button>Exception Occured:" + exp.Message + "</div>";
            }
        }
        public static void Run()
        {
            // ExStart:DetermineTableBreak
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Tables();

            // Instantiate an object PDF class
            Document pdf = new Document();
            // Add the section to PDF document sections collection
            Aspose.Pdf.Page page = pdf.Pages.Add();
            // Instantiate a table object
            Aspose.Pdf.Table table1 = new Aspose.Pdf.Table();
            table1.Margin.Top = 300;
            // Add the table in paragraphs collection of the desired section
            page.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.BorderInfo(Aspose.Pdf.BorderSide.All, 0.1F);
            // Set table border using another customized BorderInfo object
            table1.Border = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, 1F);
            // Create MarginInfo object and set its left, bottom, right and top margins
            Aspose.Pdf.MarginInfo margin = new Aspose.Pdf.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.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 = (float)pdf.PageInfo.Height;
            // Get the total height information of Page Top & Bottom margin,
            // Table Top margin and table height.
            float TotalObjectsHeight = (float)page.PageInfo.Margin.Top + (float)page.PageInfo.Margin.Bottom + (float)table1.Margin.Top + (float)table1.GetHeight();

            // Display Page Height, Table Height, table Top margin and Page Top 
            // And Bottom margin information
            Console.WriteLine("PDF document Height = " + pdf.PageInfo.Height.ToString() + "\nTop Margin Info = " + page.PageInfo.Margin.Top.ToString() + "\nBottom Margin Info = " + page.PageInfo.Margin.Bottom.ToString() + "\n\nTable-Top Margin Info = " + table1.Margin.Top.ToString() + "\nAverage Row Height = " + table1.Rows[0].MinRowHeight.ToString() + " \nTable height " + table1.GetHeight().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");


            dataDir = dataDir + "DetermineTableBreak_out.pdf";
            // Save the pdf document
            pdf.Save(dataDir);
            // ExEnd:DetermineTableBreak
            Console.WriteLine("\nTable break determined successfully.\nFile saved at " + dataDir);
            
        }
        public static void Run()
        {
            try
            {
                // ExStart:RadioButtonWithOptions
                // The path to the documents directory.
                string dataDir = RunExamples.GetDataDir_AsposePdf_Forms();

                Document         doc   = new Document();
                Page             page  = doc.Pages.Add();
                Aspose.Pdf.Table table = new Aspose.Pdf.Table();
                table.ColumnWidths = "120 120 120";
                page.Paragraphs.Add(table);
                Row  r1 = table.Rows.Add();
                Cell c1 = r1.Cells.Add();
                Cell c2 = r1.Cells.Add();
                Cell c3 = r1.Cells.Add();

                RadioButtonField rf = new RadioButtonField(page);
                rf.PartialName = "radio";
                doc.Form.Add(rf, 1);

                RadioButtonOptionField opt1 = new RadioButtonOptionField();
                RadioButtonOptionField opt2 = new RadioButtonOptionField();
                RadioButtonOptionField opt3 = new RadioButtonOptionField();

                opt1.OptionName = "Item1";
                opt2.OptionName = "Item2";
                opt3.OptionName = "Item3";

                opt1.Width  = 15;
                opt1.Height = 15;
                opt2.Width  = 15;
                opt2.Height = 15;
                opt3.Width  = 15;
                opt3.Height = 15;

                rf.Add(opt1);
                rf.Add(opt2);
                rf.Add(opt3);

                opt1.Border                      = new Border(opt1);
                opt1.Border.Width                = 1;
                opt1.Border.Style                = BorderStyle.Solid;
                opt1.Characteristics.Border      = System.Drawing.Color.Black;
                opt1.DefaultAppearance.TextColor = System.Drawing.Color.Red;
                opt1.Caption                     = new TextFragment("Item1");
                opt2.Border                      = new Border(opt1);
                opt2.Border.Width                = 1;
                opt2.Border.Style                = BorderStyle.Solid;
                opt2.Characteristics.Border      = System.Drawing.Color.Black;
                opt2.DefaultAppearance.TextColor = System.Drawing.Color.Red;
                opt2.Caption                     = new TextFragment("Item2");
                opt3.Border                      = new Border(opt1);
                opt3.Border.Width                = 1;
                opt3.Border.Style                = BorderStyle.Solid;
                opt3.Characteristics.Border      = System.Drawing.Color.Black;
                opt3.DefaultAppearance.TextColor = System.Drawing.Color.Red;
                opt3.Caption                     = new TextFragment("Item3");
                c1.Paragraphs.Add(opt1);
                c2.Paragraphs.Add(opt2);
                c3.Paragraphs.Add(opt3);

                dataDir = dataDir + "RadioButtonWithOptions_out.pdf";
                // Save the PDF file
                doc.Save(dataDir);
                // ExEnd:RadioButtonWithOptions
                Console.WriteLine("\nRadio button field with three options added successfully.\nFile saved at " + dataDir);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }