HtmlStringToPDFFile Overview

The service “HtmlStringToPDFFile” is used to generate a PDF file using HTML. The main advantage of using this service is that we can use “GetHTMLString” service from WebPart Workshop to convert WebPart into HTML string, and then generate the webpart in PDF format. The PDF generated is saved to the file path specified in the "PDFFile" input. This input contains both the file path and file name

This service also offers useful features such as header line, footer line, header html , footer html, etc. We can also adjust the height, width and choose the orientation of the PDF file that we would like to generate.

HtmlStringToPDFFile Basic Use Example

In this example we are going to use multiple services to generate a PDF from webpart, send it as an attachment, and delete the generated PDF file.

Add HtmlString

This is where we can add the HTML to convert it into PDF. In this example we are using another service called “GetHTMLString” which takes a webpartID and converts it into HTML.

Add File Name

The input “PDFFile” is the absolute path and file name of the PDF file which we would to save. Notice that we are also including .pdf extension here.


In the output logs we have three nodes:

  • FileConverted returns true or false indicating whether the file was converted to PDF or not.
  • FileSize returns size of the file created in bytes.
  • PDFFile returns the file path along with file name.