Create a Table of Contents in PDF using Power Automate

In this guide you'll learn how to add a table of contents to a PDF using Power Automate. For this example we will be adding a table of contents to your PDF in SharePoint but you can easily customize this example to destinations like Dropbox, Google Drive, OneDrive, or any platform supported by Power Automate.


Ensure the following prerequisites are in place:

  • An Office 365 subscription with a SharePoint Online license.
  • Muhimbi PDF Converter for Power Automate full subscription.
    Note: Free version does not support this functionality.
  • Appropriate privileges to create Flows.
  • Working knowledge of SharePoint Online and Microsoft Power Automate (Flow).

How to Create a Table of Contents

The steps to convert and create a Table of Content from a document is given below. The flow will look as follows:

create table of content

  1. Create a new Flow and use the SharePoint Online trigger ‘When a file is created or modified in a folder’. Fill out the URL for the site collection and select the relevant SharePoint folder from the selection.

    create a new flow

  2. Insert Muhimbi's ‘Convert document’ action and fill it out as per the screenshot displayed below. Naturally, you will need to substitute the Source file name and Source file content with suitable values.

    • Source file name:x-ms-file-name-encoded’, which is the output of the SharePoint ‘When a file is created or modified in a folder’.
    • Source file content: ‘File Content’, which is the output of the SharePoint ‘When a file is created or modified in a folder’.
    • Output format: PDF
    • Override settings:

create file

  1. Insert a ‘Create File’ action to write the converted file with the Table of Contents back to SharePoint Online.

    • File name: ‘Base File name.pdf’ is the output variable of the ‘Convert document’ action.

    • File content: ‘Processed file content’ is the output variable of the ‘Convert document’ action.

      file name

  2. Publish the workflow and upload any document. After a few seconds, the Flow will trigger and a compressed PDF file will be generated in the target location.

    Note: The best way to test this is to convert an MS Word file that contains proper heading definitions (Heading1, Heading 2 etc).

Troubleshooting / Caveats

HTML is not the best format for print or PDF Conversion purposes. Depending on your exact needs and source material, you may need to experiment with various available settings. If you have any questions or require assistance please feel free to contact us.

Please consider the following when using Power Automate:

  1. Modern Views: In SharePoint Online it is possible to display Lists and Libraries in Modern or Classic mode. Modern View is undergoing constant change (by Microsoft), as a result, we currently only support the conversion of pages displayed in Classic View. Some Modern View pages will convert fine while others don't.

  2. Multi-Factor Authentication (MFA): An increasing number of SharePoint Online / Office 365 environments are secured using MFA. Although this is a positive development, it gets in the way of automated systems such as our HTML converter. If your environment uses MFA then please create an App password for HTML conversions, or disable MFA on your HTML Conversion account.

  3. HTML Conversion option not displayed: The option to convert the current page to PDF is only available on Classic SharePoint pages. Modern pages currently do not provide a facility for extending the personal actions menu. We will make sure it is added as soon as Microsoft makes this functionality available.

  4. PDF Layout does not match: By default, the page being converted is optimized for print / PDF output. If you prefer the PDF to look exactly like what is displayed on the screen, including user interface elements, then set the Media Type to Screen in the HTML Conversion configuration screen.

  5. User-modified content is not converted: The converter does not have knowledge about the information currently displayed in the user's browser (e.g. size of the browser window, or custom data entered, but not yet submitted to the server). The converter always requests a fresh copy of the URL and converts that information to PDF.

  6. User-specific information is missing: HTML Conversion is carried out in the context of the configured user account, though the system is not aware of the user carrying out the HTML conversion. Don't specify accounts that display more information than what the users need to have access to.

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

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