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?
source share