0

For a web application with .NET Core, we'll need to generate PDF file with certain data. In some situations, the total pages could be over 1000. Is there any other way than generating in-memory PDF file and putting the total page after finishing it before turn to the web client?

EDIT: the process for getting the PDF file: client sends in request; server retrieves data and starts generating PDF file; puts page number out of total pages on each page; returns the finished PDF file stream to download to user's local computer.

Baolin Li
  • 103
  • 1
  • 7
  • If you don't want to store it in memory, can you store it in a file? – Evert May 05 '20 at 04:42
  • Are you trying to let client know how many pages the pdf will have before creating that document? – sddk May 05 '20 at 09:04
  • If store the file, when writing the total pages on each page, I'll need to read it in-memory and put the total page number on each page when finish generating the file. Each page needs to have the "Page # of #TotalPage" after the file is generated. However, as you generating the pages, you don't know how many in total until it's finished. – Baolin Li May 05 '20 at 11:45
  • Use iText DITO (https://itextpdf.com/en/products/itext-dito) to easily generate documents having page numbers out of the box – Alexey Subach May 05 '20 at 21:32
  • Hi Alexey, probably I did not clearly specify that the data to be used for generating the PDF file (report) is not from the user/client. The user/client only provides the parameters for querying/filtering data source. So the PDF generation is all behind the scene after getting the parameters. I've been able to generate the page number and out of the total pages on each page using the iText event handler. The dilemma I have is I've to keep the generated PDF file in memory before I can put the page totals on each page since only until then do I know the total number of pages. – Baolin Li May 06 '20 at 02:15

0 Answers0