Skip to main content
All CollectionsTools
Applying PDF properties
Applying PDF properties

You can apply a portable data format (pdf) for specifying the format and layout of data from your application.

Ralph Duin avatar
Written by Ralph Duin
Updated over a year ago

Warning!

This is a legacy document. The features described below are only usable within the classic generation environment.

Currently, Betty Blocks offers faster and more advanced options that are available in next-gen. Before you start working on this feature in your application, consider using the way described in Using PD-generator step article.

Good luck!

You can apply a portable data format (pdf) for specifying the format and layout of data from your application. Using a pdf as the property type, you can ensure the integrity of the information contained in an output file.

This article contains:

  • An explanation of pdf properties and templates

  • How to create a pdf property and how you associate it with a template

  • Actions that you can create that result in pdf

PDF properties and templates

Every PDF property that you create requires a template. The template defines how the details in a file are presented. You can create a template before you create a pdf property and apply that template to the property.

Note: Betty Blocks employs PrinceXML for generating PDF's. This combines a html (structure) with css (styling) and Liquid (dynamic content). Examples and templates are available on the PrinceXML website.

The setup of a PDF template is the same as a standard HTML page:

<html>
<head>
<style>
</style>
</head>
<body>
Content
</body>
</html>

You can add additional style settings in the page. For example, to set the an A3 landscape page size, specify:

 @page { 
size: A3 landscape;
}

You an also specify a page number in the bottom right of each page:

 @page { 
size: A4 portrait;
@bottom-right { content: counter(page); }
}

You can also apply cascading style sheet (CSS) formatting such as for text alignment in tables:

@page { 
size: A4 landscape;
@bottom-right { content: counter(page); }
}
table {
width:100%;
border-collapse: collapse;
}
th {
text-align:left;
padding: 3px;
}
td {
padding: 3px;
}
p {
color: grey;
}

You can dynamically load data in the table using Liquid. For example, to dynamically include specific lines of data in an invoice:

Title

Product
Description
Amount
Price

{% for line in invoicelines %}

#{{line.product.name}}
#{{line.product.description}}
#{{line.amount}}
#{{line.price}}

{% endfor %}

Creating a PDF File property

1. Click on New property in the model.

2. Open the Type menu and select Pdf as the property type. The options available are calibrated to show the pdf related options.

3. Specify a Name for the property.

4. With Static template selected, open the pull-down menu to select either New or an existing template where one exists. Only New is displayed if templates have not yet being created. Where you want to create a new template, specify a Filename (A).

Tip! The file name is a set name for the pdf file when it is downloaded. You can set a name that is related to the content in the file. For example, invoice for an invoice pdf file.

You can use the radio buttons o specify

  • Allow regenerate (B for regenerating a pdf file after it has already been generated before. This is useful when data for the file is subject to change.

  • Removable by user (C) to enable a user to delete a pdf file from a record after generation.

Where Dynamic Template (D) is selected, you can use a condition to set a template. A template is set in this field using the UUID of the template. You can find the UUID in the url when you open the template.

Example condition: A == 1 ? template X : template Y.

5. Click on the edit button. The previous IDE is opened. The name displayed shows that the file specified in step 4 is the template file displayed.

6. Specify the required HTML for the template.

7. Press the Save button the details you have applied.

8. Return to the open model property view (via the browser tab) to click Save for the newly created property.

Note:

PDF templates use variables to set data. You need to assign variables for the property so that they are used with the template.

As PDF templates use variables to set data, you need to assign variables to the property. You can open the model

Adding variables for a PDF property

You can add variables to a PDF property in the previous environment.

1. Open the list of models.

2. Select the model for which you have create a PDF property. The reservation model (A) is used in this example.

3. Click on Properties to open the property details for the model

4. Select the pdf property. In this example, the ReservationForm is

5. The property details are displayed (A). In the variable field, you can enter the details for the variables (B). Press on the Add (C) button to add additional variables.

6. Press Save to save the details you have applied.

Using PDF properties in action events

There following action events use PDF properties: 

  • Pdf generate 

  • Pdf merge

How these events are applied is explained in the following sections. As this functionality is still managed in our previous platform, the instructions below are based on the previous environment.

Note: We are constantly updating the Betty Blocks platform to increase the ease-of-use of our platform. Functionality that is currently still managed in our previous IDE may also be available in our updated platform. You can send a message using the support button where you need to check the current status when applying certain settings or building certain functionality for your application.

You can also refer to the Product changes for a list of updates to the platform.

Action Event: Pdf generate

To generate a Pdf file in the Pdf file properties of a selected object:

  1. Open Actions from the Builder Bar.

  2. Choose an action or create a new one by clicking on the New button.

  3. Set a description and a model for the action.

  4. When complete, press the Save button.

  5. Add a new action event for the action by clicking on the plus icon.

  6. A form opens. Select the Pdf Generate event in the Kind setting.

  7. Select an Object that contains a Pdf property. Press the Click to set button to open the Variables browser. Select the object that contains the PDF file that should be generated.

  8. Choose the Pdf property from the previously chosen object (step 7). If there is only one Pdf property within the object, it is automatically selected.

    Additional settings are available that you can apply.

  9. When you have completed the action event, click Save.

Action event: Pdf merge

Using this event, you can merge multiple Pdf files of the same property into one single Pdf file. If the Pdf file property does not yet contain a file, it is generated before merging. This event is always executed as a background job.

  1. Open Actions from the Builder Bar.

  2. Choose an action or create a new one by clicking on the New button on the upper left side of the screen.

  3. Set a description and a model for the action.

  4. Click on the Save button when you're done setting up the action.

  5. Add a new action event for the action by clicking on the plus icon.

  6. A form opens. Select the Pdf Merge event in the Kind setting.

  7. Select a variable in the Collection setting by clicking on the Click to set button. The collection can be accessed through a collection variable, or by a has many relation from an object.

  8. Choose the Pdf property from the previously chosen collection. If there is only one Pdf property within the chosen object's model, it is automatically selected.

  9. The PDF files is bundled into a single PDF file, and made available through the As variable.

  10. When you're done with setting up the action event, click on the Save.

Did this answer your question?