Missing column in PDF output

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");

Hello Rita,

Thanks for your interest in our products.

Last column is not being displayed in PDF because you have specified huge width value for column 3 i.e. 300. Therefore the sum of width for all columns is greater than 600 plus the default left margin value 90 for section object. So in order to properly display all the columns, you may consider using either of the following options.

  1. Reduce the width of third column to 100.
  2. Increase page width. For related information, please visit Set Page Size and Margins
  3. Set page orientation to Landscape. sec1.IsLandscape = true;

For your reference, I have attached two resultant PDF documents generated against scenario 1 and 3. In case you still face any problem or you have any further query, please feel free to contact. We apologize for your inconvenience.