We are seeing very slow performance when outputting a document to PDF. We have a data set of 1000 rows with 14 columns which takes less than a second to build the document, but from 45 to 120 seconds to export to PDF. The same export to HTML takes under 2 seconds.
This is not acceptable performance for us. Our previous export library would export this data in under 2 seconds. What can we do to speed things up?
- Code: Select all
var workbook = new Workbook();
workbook.LoadFromFile(@"C:\demo.csv", ",", 1, 1);
var sheet = workbook.Worksheets[0];
var dataTable = sheet.ExportDataTable();
var document = new Document();
var section = document.AddSection();
var table = section.AddTable(true);
var columnCount = dataTable.Columns.Count;
foreach (DataRow dataRow in dataTable.Rows)
{
var row = table.AddRow(columnCount);
foreach (DataColumn dataColumn in dataTable.Columns)
{
var columnIndex = dataTable.Columns.IndexOf(dataColumn);
var value = dataRow[dataColumn].ToString();
var cell = row.Cells[columnIndex];
var p = cell.AddParagraph();
var txt = p.AppendText(value);
}
}
Debug.WriteLine("SaveToFile Start: " + DateTime.Now.ToString());
document.SaveToFile(@"C:\demo.pdf",Spire.Doc.FileFormat.PDF);
Debug.WriteLine("SaveToFile Finish: " + DateTime.Now.ToString());