I'm generating PDFs with wkhtmltopdf
, which is awesome. However, sometimes the tool returns exit codes, but in a lot of cases, the PDF still seems to be generated properly.
How do I really know that wkhtmltopdf
failed to do the job?
Examples:
http://www.egresadoutec.edu.sv/boletin_pdf_create.php?idbXwt=101 gives a 404, but in fact the whole page was created properly (albeit 12Mb). http://www.anarchia.com/link_in_frame.php?link=7243 gives a 404 and indeed nothing was generated, but the file size is NOT 0
This is a very complicated issue actually. I sometimes want 404/500/503 pages to be rendered into a PDF normally. So what should the exit code then be? I think the exit code should be something like 2 just to inform me of what HTTP code the page returned but I still really do need the PDF to be rendered normally. I suspect that your actual issue is with the reasons for exit codes not being documented clearly, which is indeed true.
I created an issue for this, but Antialize is a busy man so he might not have time for issues like this. I actually suspect that you are calling wkhtmltopdf from some wrapper you have created yourself and you are checking the exit code there. If you don't want a PDF produced if a URL returns something other than HTTP 2xx, I suggest that you check the URL yourself before calling wkhtmltopdf. Create a tool or use an exiting one to call that URL and check it's response. Not very expensive, simple and it might work for you.