Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Mon Jan 06, 2014 4:55 am

Hi,

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

will.marriott
 
Posts: 27
Joined: Thu Oct 24, 2013 9:47 pm

Mon Jan 06, 2014 7:58 am

Hello,

Thanks for your inquiry.
Sorry for the inconvenience. Saving the document as pdf is a very complex operation, it is constituted of many steps: parsing document, splitting document to many elements with styles, placing the elements to the canvas virtual, drawing elements to images, and drawing images to pdf.
We are improving the performance. If we have a big progress, we will inform you.

Welcome to write to us again for further inquiry.

Best regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Return to Spire.PDF