HtmlToPdf(filename, [html], [usePrintCss]) Last updated: 22. Jun 2023
API only function
Converts html to a PDF file using headless Chrome.
Parameters
Name | Type | Description |
---|---|---|
filename | string | Specify output filename. |
html (optional) | string | A string containing a table to convert from HTML to PDF. If not specified, the current output buffer (using the write method) will be used as HTML content. Note that to specify usePrintCss and not html, simply pass a null value here. |
usePrintCss (optional) | bool | Use the print media when creating PDF, default is false. |
Returns
PDF file in bytes.
Example
Code example (JS)
JS is normal JavaScript either running in the browser or on the Docly™ server.// Use the write function to write to the output buffer
write('<table>');
write('<tr><th>Column1</th><th>Column2</th></tr>'); // headers
write('<tr><td>Row1Value1</td><td>Row1Value2</td></tr>'); // row 1
write('<tr><td>Row2Value1</td><td>Row2Value2</td></tr>'); // row 2
write('</table>');
return docly.HtmlToPdf("test.pdf");