public static void Run() { try { // ExStart:ManipulateTable // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_Tables(); // Load existing PDF file Document pdfDocument = new Document(dataDir + "input.pdf"); // Create TableAbsorber object to find tables TableAbsorber absorber = new TableAbsorber(); // Visit first page with absorber absorber.Visit(pdfDocument.Pages[1]); // Get access to first table on page, their first cell and text fragments in it TextFragment fragment = absorber.TableList[0].RowList[0].CellList[0].TextFragments[1]; // Change text of the first text fragment in the cell fragment.Text = "hi world"; dataDir = dataDir + "ManipulateTable_out.pdf"; pdfDocument.Save(dataDir); // ExEnd:ManipulateTable Console.WriteLine("\nTable manipulated successfully.\nFile saved at " + dataDir); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public static void Run() { // ExStart:1 // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_Tables(); // Load existing PDF document Document pdfDocument = new Document(dataDir + "Table_input2.pdf"); // Create TableAbsorber object to find tables TableAbsorber absorber = new TableAbsorber(); // Visit second page with absorber absorber.Visit(pdfDocument.Pages[1]); // Get copy of table collection AbsorbedTable[] tables = new AbsorbedTable[absorber.TableList.Count]; absorber.TableList.CopyTo(tables, 0); // Loop through the copy of collection and removing tables foreach (AbsorbedTable table in tables) { absorber.Remove(table); } // Save document pdfDocument.Save(dataDir + "Table2_out.pdf"); // ExEnd:1 }
public static void Run() { // ExStart:1 // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_Tables(); // Load existing PDF document Document pdfDocument = new Document(dataDir + "Table_input.pdf"); // Create TableAbsorber object to find tables TableAbsorber absorber = new TableAbsorber(); // Visit first page with absorber absorber.Visit(pdfDocument.Pages[1]); // Get first table on the page AbsorbedTable table = absorber.TableList[0]; // Remove the table absorber.Remove(table); // Save PDF pdfDocument.Save(dataDir + "Table_out.pdf"); // ExEnd:1 }
public static void Run() { // ExStart:1 // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_Tables(); // Load existing PDF document Document pdfDocument = new Document(dataDir + @"Table_input.pdf"); // Create TableAbsorber object to find tables TableAbsorber absorber = new TableAbsorber(); // Visit first page with absorber absorber.Visit(pdfDocument.Pages[1]); // Get first table on the page AbsorbedTable table = absorber.TableList[0]; // Create new table Table newTable = new Table(); newTable.ColumnWidths = "100 100 100"; newTable.DefaultCellBorder = new BorderInfo(BorderSide.All, 1F); Row row = newTable.Rows.Add(); row.Cells.Add("Col 1"); row.Cells.Add("Col 2"); row.Cells.Add("Col 3"); // Replace the table with new one absorber.Replace(pdfDocument.Pages[1], table, newTable); // Save document pdfDocument.Save(dataDir + "TableReplaced_out.pdf"); // ExEnd:1 }