Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
Untuk menghapus tabel, kita perlu menggunakan kelas TableAbsorber untuk mendapatkan tabel di PDF yang ada dan kemudian memanggil Remove.
Potongan kode berikut juga bekerja dengan pustaka Aspose.PDF.Drawing.
Kami telah menambahkan fungsi baru yaitu Remove() ke kelas TableAbsorber yang ada untuk menghapus tabel dari dokumen PDF. Setelah absorber berhasil menemukan tabel di halaman, ia menjadi mampu untuk menghapusnya. Silakan periksa potongan kode berikut yang menunjukkan cara menghapus tabel dari dokumen PDF:
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void RemoveTable()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf_Tables();
// Open PDF document
using (var document = new Aspose.Pdf.Document(dataDir + "Table_input.pdf"))
{
// Create TableAbsorber object to find tables
var absorber = new Aspose.Pdf.Text.TableAbsorber();
// Visit first page with absorber
absorber.Visit(document.Pages[1]);
// Get first table on the page
Aspose.Pdf.Text.AbsorbedTable table = absorber.TableList[0];
// Remove the table
absorber.Remove(table);
// Save PDF document
document.Save(dataDir + "RemoveTable_out.pdf");
}
}
Terkadang dokumen PDF mungkin berisi lebih dari satu tabel dan Anda mungkin memiliki kebutuhan untuk menghapus beberapa tabel darinya. Untuk menghapus beberapa tabel dari dokumen PDF, silakan gunakan potongan kode berikut:
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void RemoveMultipleTables()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf_Tables();
// Open PDF document
using (var document = new Aspose.Pdf.Document(dataDir + "Table_input2.pdf"))
{
// Create TableAbsorber object to find tables
var absorber = new Aspose.Pdf.Text.TableAbsorber();
// Visit second page with absorber
absorber.Visit(document.Pages[1]);
// Get copy of table collection
Aspose.Pdf.Text.AbsorbedTable[] tables = new Aspose.Pdf.Text.AbsorbedTable[absorber.TableList.Count];
absorber.TableList.CopyTo(tables, 0);
// Loop through the copy of collection and removing tables
foreach (var table in tables)
{
absorber.Remove(table);
}
// Save PDF document
document.Save(dataDir + "RemoveMultipleTables_out.pdf");
}
}
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.