Hi
Hi Hans,
DataTable dt = new DataTable();
dt.Clear();
dt.Columns.Add(“First Name”);
dt.Columns.Add(“Last Name”);
dt.Columns.Add(“Company”);
dt.Columns.Add(“Marks”);
DataRow _ravi = dt.NewRow();
_ravi[“First Name”] = “Fahad”;
_ravi[“Last Name”] = “Adeel”;
_ravi[“Company”] = “Aspose”;
_ravi[“Marks”] = “500”;
dt.Rows.Add(_ravi);
ReturnPDF(dt, “”, “”,dataDir);
{
int totalRows = res.Rows.Count; int totalColumns = res.Columns.Count;
string code = DateTime.Now.ToString("yyyyMMddHHmmss"); Document pdfDocument = new Document();
// Get particular page Aspose.Pdf.Page pdfPage = pdfDocument.Pages.Add(); // (Aspose.Pdf.Page)pdfDocument.Pages[1];
pdfPage.PageInfo.Margin = new Aspose.Pdf.MarginInfo(); pdfPage.PageInfo.Margin.Left = 22; pdfPage.PageInfo.Margin.Right = 22; pdfPage.PageInfo.Margin.Top = 72; pdfPage.PageInfo.Margin.Bottom = 72;
Aspose.Pdf.Table table = new Aspose.Pdf.Table(); table.ColumnWidths = "100 100 50 40"; // 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(res, true, 0, 0, totalRows, totalColumns); pdfDocument.Pages[1].Paragraphs.Add(table);
string pdfFilePath = root + "" + code + ".pdf";
using (FileStream pdfFileStream = File.Create(pdfFilePath)) { // Convert the Document to a Pdf file stream pdfDocument.Save(pdfFileStream, SaveFormat.Pdf); }
}
Hi again
I have used pdf.generator in stead and was able to format pdf file as i wanted and hence the problem is no longer a problem
Thanks for your feedback. I am glad you are able to format pdf file as your requirement.
Please keep using our API and feel free to contact us for any question or concern, we will be more than happy to extend our support.
Best Regards,