Convert HTML to PDF in SharePoint

In this guide you’ll learn how to convert HTML fragments or web pages to PDF using a SharePoint Designer Workflow. In this specific example we show you how to convert a SharePoint list to a PDF format but this workflow can be used to convert any Web Page to a PDF File. This guide can be used in SharePoint Online or On-premises deployments.

One additional consideration when converting a list to PDF is whether to display the SharePoint UI in your document once it has been converted. If you prefer converting your list to a PDF without the quick launch menu start we've outlined steps to follow below.

Creating MS SharePoint Pages Without Quick Launch

To create a new page without the Quick Launch menu follow these steps:

  1. Navigate to the All Site Content screen and click gear icon and click Add a page.

  2. Enter the Title and add a List Web Part, and add a List - Expense Report

  3. On the newly created page click Add a Web Part and add the Expense Report List.

  4. Before adding the list in the page, please ensure you select the columns you want to be included in the PDF file by navigating to the List Settings in the List. For example Title, Expense Details, Attachments, Created and Created By..

  5. Under the Item Limit section set the limit to an appropriately large number. We don’t want to page through the data in batches as we want to include all items in the PDF file.

  6. Click Save button to save the changes and Publish button to publish your changes.

  7. Save the page’s URL as we need it later. E.g.
    http://gbsavdws106/sites/Demo2019/SitePages/Expense-Report.aspx

This new page will be used as the underlying layout of the PDF document. Feel free to modify it further in SharePoint designer / JQuery and remove more parts of the SharePoint user interface. You could also consider creating a minimalistic master page and applying that to the new PDFTasks page.

html to pdf designer workflow

Creating Automatic Conversion in MS SharePoint Designer

With the page in place the next thing we need to do is set up the automatic PDF Conversion using a SharePoint Designer workflow. In this example we generate a PDF file whenever the Expense Report List is modified. The generated PDF file is stored in the Shared Documents library. You can create the workflow as follows:

  1. Make sure you have the appropriate privileges to create workflows on a site collection.

  2. Create a new workflow using MS SharePoint Designer.

  3. On the Workflow definition screen, associate the workflow with the Expenses Report List, and tick the boxes next to both ‘Automatically start….’ options and proceed to the next screen.

  4. Add the Convert HTML to PDF action and click “this url” and enter the URL to the page that was created in a previous step, e.g.
    http://gbsavdws106/sites/Demo2019/SitePages/Expense-Report.aspx

  5. Click “this file” and enter the path and file name where the PDF file will be generated, e.g. Shared Documents/Expenses.pdf.

  6. Optionally, change the generated page’s orientation from “Portrait” to “Landscape”.

  7. The username and passwords are optional. By default, the credentials the Muhimbi Conversion Service runs under will be used to open the web page. For now, leave it empty.

  8. Click Publish button to activate the workflow.

    publish workflow

As a test, enter one or more items in the List. Every time an item is added or updated a PDF file is generated and written to Shared Documents/Expenses.pdf. You can access and open the PDF file to see the results.

In summary, the HTML conversion capability of the new version opens up a whole array of new possibilities. As always, upgrades are completely free, and please feel free to upgrade your converter to the latest version to enjoy all the conversion features.

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