Hello, I’m attempting to format a PDF document that I’m creating in memory, but so far I am unable to figure out how to do this.
Here is my code:
Aspose.Pdf.License asposeLicense = SetAsposePdfLicense();
var document = new Aspose.Pdf.Document();
document.DisplayDocTitle = true;
// Create document and page
document.Pages.Add();
PageCollection pages = document.Pages;
Page page = pages[1];
TextStamp textStamp = new TextStamp("Comments");
textStamp.TopMargin = 10;
textStamp.HorizontalAlignment = HorizontalAlignment.Center;
textStamp.VerticalAlignment = VerticalAlignment.Top;
// Create table to display data
Table table = new Aspose.Pdf.Table
{
ColumnAdjustment = ColumnAdjustment.AutoFitToWindow,
ColumnWidths = "60 20 20",
Border = new BorderInfo(BorderSide.All, .5f, Color.FromRgb(System.Drawing.Color.Black)),
DefaultCellBorder = new BorderInfo(BorderSide.All, .5f, Color.FromRgb(System.Drawing.Color.LightGray))
};
foreach (Page docPage in document.Pages)
{
docPage.AddStamp(textStamp);
}
foreach (Comment comment in viewModel.Comments)
{
// Add row to table
Aspose.Pdf.Row row = table.Rows.Add();
// Add table cells
row.Cells.Add("col1");
row.Cells.Add("col2");
row.Cells.Add("col3");
}
// Add table to page
document.Pages[1].Paragraphs.Add(table);
var memoryStream = new System.IO.MemoryStream();
document.Save(memoryStream);
As you can see, I’m trying to display a list of “Comment” strings. There should be three columns, the first is 60% wide, the second is 20% wide, the third is 20% wide. But it’s not working.
Am I missing something?