Convert HTML to PDF using Nintex Workflow

We recently released the Muhimbi PDF Converter Xtension for Nintex Automation Cloud. You can download it here or learn more about available Muhimbi deployments for Nintex on our product page.

In this guide you’ll learn how to convert HTML / website content to PDF using a Nintex Workflow. This guide is commonly used to convert pages such as Wikis, publishing pages, Nintex Forms, and the ‘properties page’ for Lists and Document Library items to PDF.

Note: If you are using our PDF Converter before release 8.3, you may find that particularly HTML5 pages (e.g. SP2013 and later) are rendered as bitmaps and ‘overflow CSS’ elements are cut-off. For optimum results please use release 8.3 or higher. I'ts also important to note using Nintex Workflows with SharePoint Online require a more complex process - see the Nintext for Office 365 blog post for addition details.

The key features of PDF Converter 8.3 release are as follows:

  1. Brand new conversion engine with support for JavaScript, CSS and HTML5.

  2. Support for Print and Screen CSS media types to optimize output for Print / PDF Conversion.

  3. Available to all client technology including Nintex Workflow, Nintex Forms, SharePoint Designer, Flow, Logic Apps, REST & Web Services API as well as the SharePoint User interface.

  4. Enabled by default, with the option to switch back to the legacy HTML Converter using our API or config file.

  5. The MSG and EML Converter uses the new engine by default for HTML based emails.

  6. Support for converting SharePoint Online URLs.

  7. Improved error reporting, including authentication related issues.

  8. Control conversion delay between initially loading the page, including JavaScript rendering, and starting the actual PDF Conversion process.

  9. Modify the ‘View Port’ size to allow responsive web content to output the appropriate version (e.g. mobile or desktop version).

Some Caveats

Please keep in mind that HTML is not the best format for print or PDF Conversion purposes. Although our new HTML Converter is much improved, there can still be certain situations where the output is not very well optimized . Depending on your exact needs or system settings you may need to experiment with the various settings.

We recommend you to take into account the following:

  1. When converting MS SharePoint content, it is recommended to disabled the ‘Minimal Download Strategy’ SharePoint Feature as it interrupts the conversion process. Please refer to this article for details. If this is not an option, then set the conversion delay to 1000 (milliseconds).

  2. The Conversion Services will need to authenticate against the page you are looking to convert. The HTML Converter fits in with Windows’ standard security model, so you may need to tweak the server’s internet settings as per this Knowledge Base article. Naturally you have to make sure that the account the Conversion Service runs under has the appropriate privileges to read the page that is being converted.

  3. Modern web based content is very complex and it is no longer a couple of HTML elements that make up the design of a page. External JavaScript is loaded, as is third party content in iframes, part of the page is rendered by JavaScript, CSS modifies the look and feel of the page depending on the media type. So, this means that there is no clear point in time for our Converter to start the conversion process. Our software tries to make the most of it though, and in many cases succeeds using the default settings. For those situations where HTML content is converted too early (e.g. a ‘please wait, loading’ or similar message is displayed in the converted file) it is possible to tweak the Conversion Delay setting.

  4. The converter has no knowledge of the current user’s browser session. If the user has modified the page (e.g. collapsed / opened certain sections) or has made changes to the page without saving, then the converter will not reflect those changes. When converting HTML to PDF, the Converter requests the specified URL from scratch using the credentials of the account the Conversion Service runs under.

If you have any questions or comments, please feel free to contact our friendly support desk.

Convert URL or HTML to PDF Action in Nintex Workflow

Similar to all other Nintex Activities provided by Muhimbi, the HTML to PDF Conversion activity integrates with Nintex Workflow at a deep level. It supports SharePoint 2007-2019, allows errors to be handled and also supports integration with Nintex’ iterators to deal with multiple items and loops.

A screenshot of Convert URL or HTML to PDF action has been given below.

convert html to pdf action

The fields supported by this Workflow Activity are as follows:

  • Destination Path: Enter the path to write the converted file to, either:
    • A relative path to a subsite / document library / folder, e.g. Shared Documents/Some Folder/Some File.pdf.
    • An absolute path to a different site collection, e.g. /sites/Finance/ Shared Documents/Some Folder/Some File.pdf.
      Note: Always use forward slashes (‘/’) in path names.
  • Source URL / HTML: Either a fully qualified URL of the page to convert or an HTML fragment.
  • Page Orientation: Specify if you wish to use Portrait or Landscape for the generated PDF file.
  • Username: By default all pages are requested by the conversion service using the account the service is running under. If that account has no privileges on the requested URL then specify an alternative user name in this field.
  • Password: The password associated with the optional user name. Please note that any password entered here is displayed in clear text to allow field references to be added.
  • HTML Engine: Specify which HTML conversion engine to use. Chromium (the default on most modern systems) generally produces better results, especially with SharePoint 2013 and later, but for some rare scenarios the IE (Internet Explorer) or WebKit options may work better.
  • Authentication: By default the Muhimbi PDF Converter attempts to authenticate using standard Web / HTTP / Windows authentication. However, in order to convert SharePoint Online pages, a different authentication type will need to be specified.
  • WebKit Viewport: Control the ‘virtual browser size’ to improve the rendering of responsive websites. (e.g. distinguish between mobile, tablet and desktop versions of a website)
  • Media Type: HTML is primarily aimed at displaying information on screen, not on paper. However, modern web pages - including SharePoint - use CSS to define a different look and feel for the screen and the printer. Providing the default 'WebKit' based HTML Converter is used, the converter can use Print optimized CSS (the default) or Screen optimized CSS. (The IE based converter always uses the 'Screen' option).
  • Conversion Delay: Modern web pages, including SharePoint 2013 and later, as well as SharePoint Online, use complex methods for rendering pages, often involving JavaScript. Under normal circumstances the Muhimbi Converter will convert HTML to PDF the moment the page has finished loading. However, you may want to add some milliseconds (a value of 1000 is 1 second) to allow all JavaScript to finish executing.
  • Output List ID: If you wish to carry out further actions on the generated PDF file, e.g. perform a check-in, then you can optionally write the ID of the List the PDF was written to in a workflow variable of type String.
  • Output List Item ID: Similarly to PDF List ID, the Item ID of the generated PDF file can optionally be written to a workflow variable of type Item ID (in SharePoint 2007) or Integer (in SharePoint 2010 and later versions).
  • Error Handling: Similar to the way some of Nintex’ own Workflow Activities allow errors to be captured and evaluated by subsequent actions, all of Muhimbi’s Workflow Activities allow the same. By default this facility is disabled meaning that any error terminates the workflow.

Setup Automatic PDF Conversion Using Nintex Workflow

In this simple example, a Nintex workflow retrieves the HTML file or a URL and converts it to PDF.

Note: You can customize this workflow to suit your organizational needs. The workflow example given below just has one step to demonstrate the HTML to PDF conversion. A more comprehensive example is beyond the scope of this article.

To create a new workflow, you can follow the instructions below.

create new workflow

The finished workflow

Prerequisites

Before we start building the workflow, ensure all prerequisites are in place. It is also assumed that the reader has some knowledge of building Workflows using Nintex Workflow.

  1. Make sure the PDF Converter for SharePoint On-Premises version 4.1 (or newer) is installed in line with chapter two of the Administration Guide.

  2. Naturally, Nintex Workflow will need to be installed as well.

  3. Make sure the Muhimbi.PDFConverter.Nintex.WebApp SharePoint Feature is activated using SharePoint Central Administration on the relevant Web Application.

  4. You will need to have the appropriate privileges to create workflows.

Creating a new workflow

To get started, create a new workflow and choose the blank template. Ensure the workflow doesn’t start automatically.

Adding the workflow actions

You are now ready to add the action to the workflow.

You need to add the Convert URL or HTML to PDF action listed under the Muhimbi PDF section. You can fill this section as per the image below:

add workflow action

The PDF Converter integrates with all Nintex Workflow versions.

If you leave the Destination Path empty, it will write the PDF File to the same location as the source file. For more information about the Destination Path or any of the other fields, hover the mouse over the small information icons.

The workflow is now done.

Running the workflow

You can finalize the workflow by saving and publishing it, after which the workflow is ready to be executed.

You can either run the workflow manually or schedule it to run at a specific time of your choice.
You can also use the output of one PDF Workflow Action as the input of the next Action.

Additional Resources

Have a Question?
We’re Always Happy to Help.

© Muhimbi Ltd. 2008 - 2024
This website uses cookies to ensure you get the best experience. Learn more