Create PDF
The PDF export of a form is created automatically by the HybridForms service and stored as attachment file of a form data list item.
The filename is fixed: "form.pdf".
As specified in the "Operation Manual", creation of PDF files can be disabled by setting the "PDF" flag to false.
PDF Header and Footer
When the PDF is generated, each page will have a default header and footer area.
For the header, the displayed default is the name of the form definition ("TemplateName) placed on the left hand side of the pages.
<div class="container-fluid">
<div class="row">
<div class="col-xs-12 text-right"><span class="TemplateName"></span></div>
</div>
</div>
The default footer contains three values:
the name of the user, who last edited the form, on the left,
the date of the last change in the center and
the page numbering - current page plus the total number of pages of this document.
<div class="container-fluid">
<div class="row">
<div class="col-xs-12 text-right"><span class="TemplateName"></span></div>
</div>
</div>
Note: The used date format is defined by the HF.Culture setting in the HF.Formdefinition.
Customizing Header and Footer
To create your own header and/or footer layout upload specially named files to your HF.Formdefinition. For the header, the file has to be named pdf.header, for the footer, the file needs to be named pdf.footer.
Open the files with an HTML editor, just as you are used to, as these files are simple HTML code snippets.
Example files
The files contain only code snippets, please don't provide complete HTML-files.
The starting div of the snippets should contain the class "container-fluid"
to integrate the snippets to your form template correctly.
Inside the row you can insert further divs containing the content to print in your header/footer and define the size of each div by a CSS class ("col-xs-#"
- range from 1 to 12). Assure that the sum of your defined CSS columns (`"col-xs-#") in a row does not exceed 12.
<div class="pdf-header-footer pdf-header container-fluid">
<div class="row">
<div class="col-xs-12 text-right"><span class="TemplateName"></span></div>
</div>
</div>
Custom example - pdf.header:
In this example a field value ("field_id") is inserted, styled as heading <h1>
and styled by a custom CSS class green
defining the font color.
<div class="container-fluid">
<div class="row">
<div class="col-xs-6 green"><h1><span class="field_id"></span></h1></div>
<div class="col-xs-6 text-right"><img src="{{HFFormPath}}/xxxx-wohnen-LOGO.png" height="50" alt="XXXX Wohnen" /></div>
</div>
</div>
Customized header
The CSS classes "text-right"
and "col-xs-#"
are predefined CSS classes and don't have to be implemented in your custom CSS files.
<div class="container-fluid">
<div class="row">
<div class="col-xs-6">
<span class="Editor"></span>
</div>
<div class="col-xs-6 text-right">
<span class="Modified datetime"></span>
</div>
</div>
</div>
Custom example - pdf.footer:
<div class="container-fluid">
<div class="row">
<div class="col-xs-6">
XXXX Immobilien Verwaltungs GmbH
</div>
<div class="col-xs-6 text-right">T: +43 316 xxxxxx</div>
</div>
</div>
<div class="row">
<div class="col-xs-6">
Glacisstraße 69, 8010 Graz
</div>
<div class="col-xs-6 text-right">
E: <a href="mailto:office@xxxxwohnen.at">office@xxxxwohnen.at</a></div>
</div>
</div>
</div>
Customized footer
Do not upload any files with an ".html" extension in the form definition beside the form definition HTML-file itself, it will break the form.
Adding form values
To get the field values from the form values, or print fields like editors name, simple add <span>
tags, and give them a class name exactly matching the name of the control from the form definition.
<span class="Author"></span>
(<span class="Modified datetime"></span>)
The content of the SharePoint Author field will be inserted into the <span>
tag.
When printing date fields, you have to add an extra class "datetime" to indicate the tag should be treated as date and printed according to the current culture.
To format the printed date please add the date-format
attribute (e.g. date-format="MMM dd yyyy"
, date-format="HH:mm"
).
All formats supported: http://docs.telerik.com/kendo-ui/framework/globalization/dateformatting
To overrule the locale used for date formatting, you can add the "date-locale" attribute. The default locale is the form culture.
The "Now" variants are only printed by addition of date-format
!
Beside the fields from your form definition, you can use the following fields:
- Author – the user that created the form
- AuthorEmail – email of this user (if any)
- Created – Creation date of the form item (datetime)
- Culture – the HF.Culture field of the form definition
- Editor – the user that last changed the form
- EditorEmail – email of this user (if any)
- ItemID - HF.ItemID field
- Modified – Date of the last modification of the form item (datetime)
- Now date – Date of the last PDF creation date
- Now datetime – Date of the last PDF creation date and time
- Now time – Date of the last PDF creation time
- StageID - the id of the current form stage
- StageLabel – the label of the current form stage
- Status – value of the HF.Status field
- New, Edit, Approved, Deleted, Group, Archived
- TemplateID – HF.FormID of the form definition
- TemplateName – the name of the form definition
- Title – the form "Title"
Adding variable content
Images or text used besides the form field values are usually "static" content.
By calling a JavaScript function it is possible to include content based on variables.
The JavaScript function can be implemented by declaring a HFCustomString
in your pdf.header or pdf.footer file.
- HTML
- TypeScript
<div class="pdf-header-footer pdf-header container-fluid">
<div class="row">
<div class="col-xs-8"><h2>HybridForms® – Software for Mobile Business</h2></div>
<div class="col-xs-4 text-right" style="margin-top:10px">{{HFCustomString:HFFormdefinition.DemoTrainingHelpers.pdfReturn}}</div>
</div>
</div>
export function pdfReturn() {
const changelogo = HybridForms.API.FormControls.getCtrl('radiov5').val();
let url = '';
if (changelogo === true) {
url = HybridForms.API.FormDefinition.getAttachmentPath('form-logo_1.png') + '/form-logo_1.png';
} else {
url = HybridForms.API.FormDefinition.getAttachmentPath('form-logo_2.png') + '/form-logo_2.png';
}
if (url) {
return(`<img src="${url}">`);
} else {
return('<h4>No logo</h4>');
}
}
In this example the logo is changed depending on the RadioBox value:
Images have to be available besides the form template definition at your server.