Slow creation of iTextSharp PdfReader with large fillable form

I have a large (6 page, 222 margin) fillable PDF that I use as a template with iTextSharp PdfReader. When this object is created, it takes 5 minutes or more. I tried:

string pdfPath = Path.Combine(context.Server.MapPath("~/apps/ssgenpdf/App_Data"), "07-2011 Worksheets.pdf"); reader = new PdfReader(pdfPath); 

As an alternative, I tried to read the file in the memory stream and pass the memory stream to the PdfReader constructor. In addition, I tried using:

 reader = new PdfReader(new RandomAccessFileOrArray(pdfPath), null); 

none of these alternatives show significant gains.

This is an ASP.Net application, so my temporary solution is to do this creation when the application starts up and the reader is cached, and then I check if I can get a valid reader from the cache and create a new reader from this reader. Now I usually see a 50 millisecond response from this approach.

I worry that this does not seem scalable if others in my group want to use this "fillable PDF as template with iTextSharp" strategy. Does anyone have suggestions for alternative strategies to balance performance with scalability?

+6
source share
1 answer

Make sure that the PDF file you are using is the same both on the server and locally. Sometimes they are damaged from the source control. [I have a problem with VSS with fillable PDF forms that I created through nitro.] It is also better to ask a question and the corresponding forum http://forum.pdfsharp.net

0
source

Source: https://habr.com/ru/post/895436/


All Articles