Page tree
Skip to end of metadata
Go to start of metadata

Overview

FileInfo Files.AddPDF ( htmlContent, name, [ options ] )

 Adds a new PDF file to repository with html content and returns created file info.

Arguments

String htmlContent

 Content of file in HTML format.

String name

Name of file.

Object options

PDF generating options. See remarks.

Option may contain one or more following properties:

Number MarginLeft

Specifies the page margin in millimeters. (Default 20mm)

Number MarginRight

Specifies the page margin in millimeters. (Default 20mm)

Number MarginTop

Specifies the page margin in millimeters. (Default 20mm)

Number MarginBottom

Specifies the page margin in millimeters. (Default 20mm)

Number PageWidth

Specifies the page width in millimeters.

Number PageHeight

Specifies the page height in millimeters.

String HeaderHtml

Specifies html content to be inserted top of every page.

Number HeaderSpacing

Spacing between header and content in millimeters.

String FooterHtml

Specifies html content to be inserted bottom of every page.

Number FooterSpacing

Spacing between footer and content in millimeters.

String Style

CSS style to apply on content and header and footer html.

String Orientation

Orientation of page. Can set to one of "Portrait" or "Landscape" value. Default value is "Portrait"


Remarks

Header and footer html parameters specifies the single page and may contain following parameters:

ParameterDescription
[page]Current page number
[frompage]First page number
[topage]Total number of pages
[customField]Other custom property specified in options.
Sample header html
<table style="border-bottom: 1px solid black; width: 100%;">
   <tr>
     <td style="width:20%;text-align:center;">[logo]</td>
     <td style="width:50%;text-align:center;font-size:1.3em;">[documentTitle]</td>
     <td style="width:30%">
       Document Number : [documentNumber]<br />
       Page : [page]/[topage]
     </td>
   </tr>
 </table>

Examples

Usage
var html = '<html><body>Hello!</body></html>';
 
var pdfFile = $Files.AddPDF(html, 'sample.pdf');
 
return pdfFile.Id;


See Also