I have just downloaded the trial version of Aspose PDF for .NET component. I am trying to convert the data table gridview to PDF. However I came across the problem where the last column seems to be truncated when I check the output in PDF format. Below is the sample codes that I am working on. Thanks for your help.
DataTable dt = (DataTable)ViewState["olinDT"];
//Instantiate a Pdf instance
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
//Create a section in the Pdf instance
Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();
//Create a Table object
Aspose.Pdf.Generator.Table tab1 = new Aspose.Pdf.Generator.Table();
//Add the Table object in the paragraphs collection of the section
sec1.Paragraphs.Add(tab1);
//Set column widths of the table
tab1.ColumnWidths = "40 100 300 100 100";
//Set default cell border of the table using BorderInfo object
tab1.DefaultCellBorder = new Aspose.Pdf.Generator.BorderInfo((int) Aspose.Pdf.Generator.BorderSide.All,0.1F);
//Import data into the Table object from the DataTable created above
tab1.ImportDataTable(dt,true,0,0,dt.Rows.Count,5);
//Get 1st row from the table
Aspose.Pdf.Generator.Row row1 = tab1.Rows[0];
//Iterate through all cells in the row and set their background color to blue
//foreach (Aspose.Pdf.Generator.Cell curCell in row1.Cells)
//{
// curCell.BackgroundColor = new Aspose.Pdf.Generator.Color("DarkBlue");
//}
int rowInd = 0;
int modVal = 0;
foreach (Aspose.Pdf.Generator.Row curRow in tab1.Rows)
{
rowInd++;
modVal = rowInd % 2;
if (modVal == 0)
{
curRow.BackgroundColor = new Aspose.Pdf.Generator.Color("PaleTurquoise");
}
}
// pdf1.BindHTML(stream_reader);
//add customed header to every section of the pdf object
foreach (Section sec2 in pdf1.Sections)
{
HeaderFooter hf1 = new HeaderFooter(sec2);
//Set the header of odd pages of the PDF document
sec2.OddHeader = hf1;
//Set the header of even pages of the PDF document
sec2.EvenHeader = hf1;
//Instantiate a Text paragraph that will store the content to show as header
Text text = new Text(hf1, "This is a header");
//Add the text object to the Paragraphs collection of HeaderFooter object to
//display header on the pages of PDF document
text.TextInfo.Alignment = AlignmentType.Center;
hf1.Paragraphs.Add(text);
}
//Save the Pdf
pdf1.Save("MyTestPDF.pdf");