Hi
Hi Patrick,
Document pdfDocument = new Document(“c:/pdftest/input.pdf”);<o:p></o:p>
// Get particular page
Page pdfPage = (Page)pdfDocument.Pages[1];
// Create a table
Table table = new Table();
// Set the table border color as LightGray
Aspose.Pdf.Color baseColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.FromArgb(0, 0, 40, 160));
table.DefaultCellTextState.ForegroundColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.FromArgb(0, 40, 160));
table.Border = new BorderInfo(BorderSide.All, .5f, baseColor);
// Set the border for table cells
table.DefaultCellBorder = new BorderInfo(BorderSide.All, .5f, Aspose.Pdf.Color.FromRgb(System.Drawing.Color.LightGray));
table.BackgroundColor = Aspose.Pdf.Color.LightGray;
Row row = table.Rows.Add();
row.Border = new BorderInfo(BorderSide.All, .5f, baseColor);
MarginInfo marginInfo = new MarginInfo
{
Top = 5,
Left = 5,
Bottom = 5
};
row.DefaultCellPadding = marginInfo;
TextState textState = new TextState();
textState.Font = FontRepository.FindFont("Arial");
textState.FontSize = 9;
textState.FontStyle = FontStyles.Bold;
Cell cell1 = row.Cells.Add("Text", textState);
cell1.ColSpan = 2;
MarginInfo marginInfoLines = new MarginInfo
{
Top = 2,
Left = 5,
Bottom = 2
};
// Add row to table
Row lines = table.Rows.Add();
lines.DefaultCellPadding = marginInfoLines;
TextState textStateLines = new TextState();
textStateLines.Font = FontRepository.FindFont("Arial");
textStateLines.FontSize = 7;
// Add table cells
lines.Cells.Add("Text");
lines.Cells.Add("Text");
// Enter some test
for (int rowCount = 0; rowCount < 2; rowCount++)
{
// Add row to table
Row approver = table.Rows.Add();
approver.DefaultCellPadding = marginInfoLines;
// Add table cells
approver.Cells.Add("", textStateLines);
approver.Cells.Add("Test", textStateLines);
}
// Add table object to first page of input document
table.Top = 100;
table.Left = 100;
pdfPage.Paragraphs.Add(table);
// Check if PDF/A Compliant, than convert to PDF/A
if (pdfDocument.IsPdfaCompliant)
{
pdfDocument.Convert(new MemoryStream(), PdfFormat.PDF_A_2A, ConvertErrorAction.Delete);
}
MemoryStream pdfStream = new MemoryStream();
pdfDocument.Save("c:/pdftest/TableAdded.pdf");
Hi
Hi Patrick,