DocRaptor

Managing Errors in your HTML to PDF Pipeline

When you view an ordinary web page, many errors may occur without your knowledge. The page itself may fail to load, or resources (such as images and stylesheets) may fail to download, be sent using bad encoding, have unknown MIME types, or any number of other common errors.

As long as the page loads, your browser attempts to display the page and it ignores any errored images or stylesheets. You can see these errors will appear in the browser’s development console.

By default, DocRaptor’s HTML to PDF service works the same way. We’ll ignore resource errors and only actually fail your document if the web page itself rails. Any resource errors encountered will be logged, but you’ll never know the error occured without checking the document log.

Often, you may want an image 404 error or an external Javascript DNS issue to fail the entire document. A resource failure likely means you’re displaying a broken or incomplete document to your customers! If you’d prefer your document to fail when a resource error occurs, simply set the doc[ignore_resources_error] API parameter to false.

Obviously, if your document fails, you’ll want to make sure this error alerts your development team through error logging or application monitoring.

We’ll fail the document if we encounter any of the following errors:

  • Connection Timeouts
  • 400s
  • 500s
  • DNS Resolution errors
  • Unknown MIME types
  • SSL Issues
  • Rejected Connections