Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
Aspose.PDF for .NET이 지원하는 초기 기능 중 하나는 테이블 작업 기능이며, 이는 처음부터 생성된 PDF 파일이나 기존 PDF 파일에 테이블을 추가하는 데 큰 지원을 제공합니다. 또한 데이터베이스 내용을 기반으로 동적 테이블을 생성하기 위해 테이블을 데이터베이스(DOM)와 통합할 수 있는 기능도 제공합니다. 이번 새로운 릴리스에서는 PDF 문서 페이지에 이미 존재하는 간단한 테이블을 검색하고 구문 분석하는 새로운 기능을 구현했습니다. Aspose.PDF.Text.TableAbsorber라는 새로운 클래스가 이러한 기능을 제공합니다. TableAbsorber의 사용법은 기존 TextFragmentAbsorber 클래스와 매우 유사합니다. 다음 코드 스니펫은 특정 테이블 셀의 내용을 업데이트하는 단계를 보여줍니다.
다음 코드 스니펫은 Aspose.PDF.Drawing 라이브러리와도 작동합니다.
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void ManipulateTable()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf_Tables();
// Open PDF document
using (var document = new Aspose.Pdf.Document(dataDir + "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 access to first table on page, their first cell and text fragments in it
Aspose.Pdf.Text.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";
// Save PDF document
document.Save(dataDir + "ManipulateTable_out.pdf");
}
}
특정 테이블을 찾아 원하는 테이블로 교체해야 하는 경우, TableAbsorber 클래스의 Replace() 메서드를 사용하여 이를 수행할 수 있습니다. 다음 예제는 PDF 문서 내에서 테이블을 교체하는 기능을 보여줍니다.
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void ReplaceTable()
{
// 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 first page with absorber
absorber.Visit(document.Pages[1]);
// Get first table on the page
Aspose.Pdf.Text.AbsorbedTable table = absorber.TableList[0];
// Create new table
var newTable = new Aspose.Pdf.Table();
newTable.ColumnWidths = "100 100 100";
newTable.DefaultCellBorder = new Aspose.Pdf.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(document.Pages[1], table, newTable);
// Save PDF document
document.Save(dataDir + "ReplaceTable_out.pdf");
}
}
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.