PDF creation using iTextsharp taking too much of time

别来无恙 提交于 2020-01-05 04:06:08

问题


Iam using ASP.Net along with iTextsharp to generate PDF files. Data is returned from SQL Server in to ASP.Net in the form of a DataTable. For example if my datatable contains 1000 records with varying company id and branch id, my requirement is to write PDFs grouped by companyid and branch id.

CompanyID     Code    Name   BranchId   Amount
1             XXXX    xxx      10        XXXX
1             XXXX    xxx      20        XXXX
5             XXXX    xxx      20        XXXX
1             XXXX    xxx      10        XXXX
1             XXXX    xxx      10        XXXX
2             XXXX    xxx      30        XXXX
5             XXXX    xxx      30        XXXX
3             XXXX    xxx      20        XXXX
1             XXXX    xxx      50        XXXX
4             XXXX    xxx      20        XXXX
6             XXXX    xxx      20        XXXX
4             XXXX    xxx      10        XXXX

My main problem is that its taking too much time to generate PDFs. My logic is simple:

foreach companyId in distinct Companylist
    foreach branchid in companyId
      Populate data based on a HTML template
      Write the HTML output to PDF using iTextsharp
    loop
loop

Is there any better approach? For 200 records, it took 30minutes to generate the PDFs. How do I minimize the time. Please help.

来源:https://stackoverflow.com/questions/38739843/pdf-creation-using-itextsharp-taking-too-much-of-time

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!