How to allow successful build of a docfx project without a valid path to wkhtmltopdf.exe?

I have a docfx project in my solution and I’ve configured it to create a PDF file of the user documentation. This function works well, but requires an installed local copy of wkhtmltopdf and the path to wkhtmltopdf.exe be set in docfx.json file.

If the path to the wkhtmltopdf.exe in the docfx.json file is incorrect, not set, or does not exist, the whole project is unable to build and throws the following exception:
enter image description here

Is there a way to still allow the project to build and maybe throw a warning instead of an error about how the wkhtmltopdf.exe file was not found? I see no reason why I shouldn’t want the project to launch just because the PDF could not be generated.

docfx.json section with PDF settings:

{
  "pdf": {
    "content": [
      {
        "files": [ "**/articles/*.{md,yml}" ]
      }
    ],
    "resource": [
      {
        "files": [ "**/articles/img/**" ]
      }
    ],
    "wkhtmltopdf": {
      "additionalArguments": "--enable-local-file-access",
      "filePath": "C:\\Program Files\\wkhtmltopdf\\bin\\wkhtmltopdf.exe"
    },
    "dest":  ".\\pdf"
  },
  ... other settings
}

Leave a Comment