Hi
Hi Michal.
Thanks for sharing the details.
I have tried executing the code snippet which you have shared but there are many variables which are not defined. Furthermore, I have observed that you are using legacy Aspose.Pdf.Generator and there might be some issues when using older approach. However in order to replicate the issue, I have tried using the following code snippet based on the new Document Object Model and I am unable to notice any issue. Can you please try using the latest DOM and in case you still face any issue, please share the complete code snippet so that we can again try replicating the issue in our environment. We are sorry for your inconvenience.
[C#]
DataTable dt = new DataTable("Employee");
dt.Columns.Add("Employee_ID",
typeof(Int32));
dt.Columns.Add("Employee_Name",
typeof(string));
dt.Columns.Add("Gender",
typeof(string));
//Add 2 rows into the DataTable object programmatically
DataRow dr = dt.NewRow();
dr[0] = 1;
dr[1] = "John Smith";
dr[2] = "Male";
dt.Rows.Add(dr);
dr = dt.NewRow();
dr[0] = 2;
dr[1] = "Mary Miller";
dr[2] = "Female";
dt.Rows.Add(dr);
// Create Document instance
Document doc = new Document();
doc.Pages.Add();
// Initializes a new instance of the Table
Aspose.Pdf.Table table = new Aspose.Pdf.Table();
//Set column widths of the table
table.ColumnWidths = "40 100 100 100";
// Set the table border color as LightGray
table.Border = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, .5f, Aspose.Pdf.Color.FromRgb(System.Drawing.Color.LightGray));
// set the border for table cells
table.DefaultCellBorder = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, .5f, Aspose.Pdf.Color.FromRgb(System.Drawing.Color.LightGray));
table.ImportDataTable(dt, true, 0, 1, 3, 3);
for (int i = 0; i < dt.Rows.Count; i++)
{
if (dt.Rows[i][2].ToString() == "")
{
table.Rows[i].Cells[1].ColSpan = 2;
}
}
// Add table object to first page of input document
doc.Pages[1].Paragraphs.Add(table);
// Save updated document containing table object
doc.Save("c:/pdftest/DataIntegrated.pdf");
Hi, thanks for your answer.
Hi Michal,
Hi,
Please test this code, it works the same as my code.
{
// The path to the documents directory.
string dataDir = Path.GetFullPath("…/…/…/Data/");
// Create directory if it is not already present.
bool IsExists = System.IO.Directory.Exists(dataDir);
if (!IsExists)
System.IO.Directory.CreateDirectory(dataDir);
DataTable dt = new DataTable(“Employee”);
dt.Columns.Add(“Employee_ID”, typeof(Int32));
dt.Columns.Add(“Employee_Name”, typeof(string));
dt.Columns.Add(“Gender”, typeof(string));
dt.Columns.Add(“Test”, typeof(string));
//Add 2 rows into the DataTable object programmatically
DataRow dr = dt.NewRow();
dr[0] = 1;
dr[1] = “John Smith”;
dr[2] = “test”;
dr[3] = “”;
dt.Rows.Add(dr);
dr = dt.NewRow();
dr[0] = 2;
dr[1] = “Mary Miller”;
dr[2] = “Female”;
dr[3] = “123”;
dt.Rows.Add(dr);
dr = dt.NewRow();
dr[0] = 2;
dr[1] = “”;
dr[2] = “Female”;
dr[3] = “123”;
dt.Rows.Add(dr);
dr = dt.NewRow();
dr[0] = 3;
dr[1] = “Mary Miller”;
dr[2] = “Female”;
dr[3] = “123”;
dt.Rows.Add(dr);
dr = dt.NewRow();
dr[0] = 4;
dr[1] = “”;
dr[2] = “Female”;
dr[3] = “123”;
dt.Rows.Add(dr);
// Create Document instance
Document doc = new Document();
doc.Pages.Add();
// Initializes a new instance of the Table
Aspose.Pdf.Table table = new Aspose.Pdf.Table();
//Set column widths of the table
table.ColumnWidths = “40 100 100 100”;
// Set the table border color as LightGray
table.Border = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, .5f, Aspose.Pdf.Color.FromRgb(System.Drawing.Color.LightGray));
// set the border for table cells
table.DefaultCellBorder = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, .5f, Aspose.Pdf.Color.FromRgb(System.Drawing.Color.LightGray));
table.ImportDataTable(dt, false, 0, 0, dt.Rows.Count, dt.Columns.Count);
for (int i = 0; i < dt.Rows.Count; i++)
{
if (dt.Rows[i][1].ToString() == “”)
{
table.Rows[i].Cells[0].ColSpan = 2;
}
}
// Add table object to first page of input document
doc.Pages[1].Paragraphs.Add(table);
// Save updated document containing table object
//doc.Save(“c:/pdftest/DataIntegrated.pdf”);
doc.Save(dataDir+ “IsNewPageProperty_Test.pdf”);
System.Diagnostics.Process.Start(dataDir + “IsNewPageProperty_Test.pdf”);
}
Hi Michal,
notice the same problem. For the sake of correction, I have logged this problem
as PDFNEWNET-39979 in our issue tracking system. We will
further look into the details of this problem and will keep you updated on the
status of correction. Please be patient and spare us little time. We are sorry
for this inconvenience.