PDF tools
Jetveo offers a built-in tool for manipulating PDF documents. Accessible at App.Tools.Pdf
.
Generating PDF documents
The primary purpose of this tool is generating a pdf document from an html string. The html string is typically generated from a template. The tool provides a method App.Tools.Pdf.GenerateFromHtml()
That takes in 8 arguments:
string documentHtml
The html string, the pdf document is generated from.
Optional Arguments
headerHtml
An html string, that will define the header.footerHtml
An html string, that will define the footer.paperSize
An enum, that contains a few known paper sizes. (Default A4)scale
A floating-point number, that sets the scaling (Default 1.0)margins
An enum, which lets you choose margins fromLarge
,Normal
,None
.headerExtraMargin
A floating-point margin size (Note: The value is in inches)footerExtraMargin
...
The method returns a byte array, containing the pdf file content. To add the generated document as a revision,
use x.AddRevision(fileName, generatedPdfContent)
, where
x
is the desired document to update.fileName
is a string, with the desired file name.generatedPdfContent
is the byte array returned fromGenerateFromHtml()
Here is a simple usage example
public void GenerateAgreementPdf(Customer customer)
{
var html_string = App.Templates.AgreementTemplate.Render(customer);
var pdf_content = App.Tools.Pdf.GenerateFromHtml(html_string);
string file_name = $"agreement_{customer.Name}.pdf";
customer.Agreement.AddRevision(file_name, pdf_content);
}