Skip to content

AddPDF

Adds a new PDF file to the repository with HTML content and returns the created FileInfo.

1
myFiles.AddPDF(html: string, name: string, options: `FooterHtml` : string

Gets or sets the HTML content to use as the footer on all pages in the document.

FooterSpacing : number
Gets or sets the space between the footer and the page content. The default is 0.

HeaderHtml : string
Gets or sets the HTML content to use as the header on all pages in the document.

HeaderSpacing : number
Gets or sets the space between the header and the page content. The default is 0.

MarginBottom : number
Gets or sets the bottom margin of the page.

MarginLeft : number
Gets or sets the left margin of the page. The default is '10mm'.

MarginRight : number
Gets or sets the right margin of the page. The default is '10mm'.

MarginTop : number
Gets or sets the top margin of the page.

Orientation : ( "Landscape" | "Portrait" )
Gets or sets the page orientation.

PageHeight : number
Gets or sets the page height.

PageSize : ( "A1" | "A2" | "A3" | "A4" | "A5" | "A6" | "A7" | "A8" | "A9" | "B0" | "B1" | "B2" | "B3" | "B4" | "B5" | "B6" | "B7" | "B8" | "B9" | "B10" | "C5E" | "Comm10E" | "DLE" | "Executive" | "Folio" | "Ledger" | "Legal" | "Letter" | "Tabloid" )
Gets or sets the predefined page size. The default is 'A4'.

PageWidth : number
Gets or sets the page width.

Style : string
Gets or sets the CSS style to include in the page.):FileInfo

Parameters

string html
    The content of the file in HTML format.

string name
    The name of the file.

FooterHtml : string
Gets or sets the HTML content to use as the footer on all pages in the document.

FooterSpacing : number
Gets or sets the space between the footer and the page content. The default is 0.

HeaderHtml : string
Gets or sets the HTML content to use as the header on all pages in the document.

HeaderSpacing : number
Gets or sets the space between the header and the page content. The default is 0.

MarginBottom : number
Gets or sets the bottom margin of the page.

MarginLeft : number
Gets or sets the left margin of the page. The default is '10mm'.

MarginRight : number
Gets or sets the right margin of the page. The default is '10mm'.

MarginTop : number
Gets or sets the top margin of the page.

Orientation : ( "Landscape" | "Portrait" )
Gets or sets the page orientation.

PageHeight : number
Gets or sets the page height.

PageSize : ( "A1" | "A2" | "A3" | "A4" | "A5" | "A6" | "A7" | "A8" | "A9" | "B0" | "B1" | "B2" | "B3" | "B4" | "B5" | "B6" | "B7" | "B8" | "B9" | "B10" | "C5E" | "Comm10E" | "DLE" | "Executive" | "Folio" | "Ledger" | "Legal" | "Letter" | "Tabloid" )
Gets or sets the predefined page size. The default is 'A4'.

PageWidth : number
Gets or sets the page width.

Style : string
Gets or sets the CSS style to include in the page. options
    Options for PDF conversion.

Returns

The created FileInfo.

Remarks

The headerHtml and footerHtml parameters specify the content for a single page and may contain the following parameters:

  • [page]: The current page number.
  • [frompage]: The first page number.
  • [topage]: The total number of pages.
  • [customField]: Other custom properties specified in the options.

Define reusable header HTML for PDF conversion

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
<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>

Convert HTML into a PDF file

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

See Also