0

I'm using NReco PDF generator to create PDFs of some fairly lengthy html tables. Most of the time it works fine, but sometimes it will generate a PDF that's just two blank pages (one blank page where the cover would be, followed by a blank page with the correct header and footer). I don't think anything is wrong with the html itself, since it does successfully generate the full document with the same input other times.

Could this be a timeout issue due to the large number of pages? Per another post I saw, I tried initializing the converter with this optional argument, but it didn't help:

NReco.PdfGenerator.HtmlToPdfConverter pdfConverter = new NReco.PdfGenerator.HtmlToPdfConverter{ CustomWkHtmlPageArgs = " --no-stop-slow-scripts" };

Is there anything else I should adjust, or does anyone know what else could be causing this?

Update: This is primarily happening in Chrome. I have the PDF generating in the browser in a new tab, and I thought it might be a caching issue, so I added a timestamp parameter in the url so it would be unique each time, but that didn't seem to help.

Final Update: adding --javascript-delay 2500 to the CustomWkHtmlPageArgs seems to have fixed the problem, so I think it must have been an issue with the PDF generating before the data was fully loaded.

user3562286
  • 151
  • 2
  • 13
  • NReco.PdfGenerator executes wkhtmltopdf under the hood, and it definitely 'randomly' add blank pages by itself - PDF output is _fully_ depends on your input HTML. – Vitaliy Fedorchenko Sep 25 '20 at 06:55
  • Hi Vitaliy, what would cause the exact same html input to sometimes render correctly and other times render blank pages? I tried adding --javascript-delay 2500 to the CustomWkHtmlPageArgs, and that seems to have helped some, so I'm wondering if it was somehow a question of the data not being fully loaded sometimes before it tried to generate the pdf. The data is being passed to the page as a form variable. – user3562286 Sep 25 '20 at 17:17

1 Answers1

0

adding --javascript-delay 2500 to the CustomWkHtmlPageArgs seems to have fixed the problem, so I think it must have been an issue with the PDF generating before the data was fully loaded.

user3562286
  • 151
  • 2
  • 13