[Html2PdfConverter] Return codes seem wrong
Forge component by Miguel 'Kelter' Antunes
Published on 02 Jun 2020
Application Type
Traditional Web

When I look inside the .NET code, I find the following lines:

// if 0 or 2, it worked so return path of pdf

if ((returnCode == 0) || (returnCode == 2)) {

When looking at the wkhtmltopdf "documentation" however, I find the following return codes. Should the component be updated? Is the documentation wrong? 

The component works fine in our dev environment, but in test, it fails each time, and upon furhter investigation, it seems to return code 1. Which seems acceptable for me, but the component just writes is of as "failed" with an empty error message.

0All OK
1PDF generated OK, but some request(s) did not return HTTP 200
2Could not something something
XCould not write PDF: File in use
YCould not write PDF: No write permission
ZPDF generated OK, but some JavaScript requests(s) timeouted
AInvalid arguments provided
BCould not find input file(s)
CProcess timeout


Rank: #171

Hi Tim,

Maybe the adaptation for OutSystems don't use all codes from the original Library.

Is possible that the way it was implemented in OutSystems use some custom validations, since it was not a requisite back there to the developer to use all codes.

Looking for the post you linked from github, seems like this table of codes is not an original documentation, it is just a sample that some user provided, it may even exist more errors and scenarios than the ones listed, if I understand correctly.

Any way, maybe the reason the code 1 is not considered in the component as a valid return is that some part of the file could be missing due the failed requests.

You can always customize it for your needs if you want to add code 1 as a valid return.

But is also cool to wait for the feedback of the component's developer.

Cheers and Regards,

RR :)

Rank: #256

Raphael, thank you for your input.

I did check the .net code, which directly calls the wkhtmltopdf.exe and the lines of code capture the return code of that exe process, so there is no OutSystems interpretation or validation.

I know there is no official documentation on github stating the return codes (which is why I put it between ") but this is as close as I can get. I audited the whole .net code in an effort to find the true exception, because the component does a great job at hiding it. I noticed getting 1, which the code interprets as error. In dev it works with exactly the same code, so it must be returning 0 or 2 there.