How do I know if an error occured when converting html page to PDF via pdftron.PDF.Convert.HTML2PDF?

Q:

When using the HTML2PDF is there a way to know if an error occured on the html page? We can convert it to respond with a 505 response code when an error. Is there a way to determine if there is a response code on the page generation.

The following code for not converted was not executed during an error due to convert was true. The error page became the document page.

Thanks in advance,

Will

blnConverted = HTML2PDF.Convert(pdfInvoiceDocument, strOmegaPrintURL)

If Not (blnConverted) Then

Response.Write(“Unable to Create Omega Invoice!!!”)

Response.End()

End If

A:

Since the conversion is throwing exception the first thing would be to handle exceptions by using Try… Catch block. For example:

Try

blnConverted = HTML2PDF.Convert(pdfInvoiceDocument, strOmegaPrintURL) Catch e As Exception

Response.Write(“Unable to Create Omega Invoice!!!” + e) End Try

If Not (blnConverted) Then

Response.Write(“Unable to Create Omega Invoice!!!”)

Response.End()

Btw. if is false you can obtain the largest HTTP error code using HTML2PDF.GetHTTPErrorCode(). For more info please the documentation:

http://www.pdftron.com/pdfnet/PDFNetAPIRef/html/793941c5-a663-6679-33f3-caa96d081caf.htm

There is also method called HTML2PDF.WebPageSettings.SetLoadErrorHandling() that will let you choose the way you prefer to handle errors (i.e. e_ignore, e_skip, or e_abort):

http://www.pdftron.com/pdfnet/PDFNetAPIRef/html/393513d0-23aa-3a8e-0ea2-253fe5964c50.htm