Save As PDF Control
The Save as PDF control allows you to take a snapshot of a view or form at a particular point in time. You must configure this control when you're designing the view or form and configure rules to handle the events and actions of the control.
The control is not a display control and is not shown at runtime on the view or form. When using the view or form, you'll click a button or take some other action to trigger the snapshot, and a PDF file is saved to a SmartObject. At design time, you see a visual representation of the control that you can configure.
See the following resources for more information:
- How To: Save a Screenshot to PDF and Attach it to an Email
- You can also use the PDF Converter service to generate PDF's outside of views and forms. For more information see the PDF Converter Service topic.
- See How To: Use the Save As PDF Control and Show a Message to Confirm the File for an example of using the control on a view, showing a message after the control method executes and the PDF file is created.
When you configure the control, you can use one of the following SmartObjects as the data source:
- Out of the box PDF File SmartObject : You can use the pre-installed PDF File SmartObject to save all PDFs.
- Custom SmartBox SmartObject (Advanced): You can create a custom SmartObject to save PDFs. The SmartObject should have the following functions:
- Create function
- List method
- File property
- Number/Autonumber property - Map this property to a Number field when you use the control in a workflow.
Follow the steps below to use the PDF File SmartObject as the data source for the control:
- Create a Sales Order Item view to use with the control. Make sure you have a button to execute the control's method.
- Drag the control onto the view. You can find the control in the Export section of the Toolbox.
- Navigate to the rules and add a rule to execute the control's method.
- Finish the rule and then finish the view.
- Run the view and type some information.
- Click the Submit button.
- Navigate to System > Controls > Save as PDF in the category tree and create a List view of the PDF File SmartObject called PDF File List.
- Run the PDF File List view and click the link to open your PDF file.
Follow the steps below to use a custom SmartBox SmartObject as the data source for the control:
- Create a custom SmartObject called Custom PDF with an AutoNumber ID and a File property.
- Create a Sales Order Item view to use with the control. Make sure you have a button to execute the control's method.
- Drag the control onto the view. You can find the control in the Export section of the Toolbox.
- Configure the SmartObject using the Data Source of the control's properties. To do this, click the ellipsis next to SmartObject.
- The Configure SmartObject page opens and is automatically populated with the PDF File SmartObject.
- Click the ellipsis next to SmartObject and select your Custom PDF SmartObject from the category tree. Click OK.
- Configure the rest of the properties if necessary.
- Navigate to the rules and add a rule to execute the control's method.
- Finish the rule and then finish the view.
- Run the view and type information in the view.
- Click the Submit button.
- Create a List view from the Custom PDF SmartObject called Custom PDF List.
- Run the Custom PDF List view and click the link to open your PDF file.
You can find the control in the Export section of the Toolbox.
Properties | Description | Can be set in runtime using rules? |
---|---|---|
Detail | ||
Name | A unique identifier for the control. This property is required and defaults to the name of the control. | No |
Settings | ||
Append Date | Adds the date to the end of the PDF file. | Yes, see Configure the Set a Control's Properties Action for more information. |
Clean IFrames |
Cleans iframes when creating the PDF file.
|
Yes, see Configure the Set a Control's Properties Action for more information. |
File Name | The name for the PDF file. Use rules and expressions if you want to use a unique name for each PDF file. | Yes, see Configure the Set a Control's Properties Action for more information. |
Page Size | A drop-down list containing the page sizes of the PDF. | Yes, see Configure the Set a Control's Properties Action for more information. |
Page Orientation |
A drop-down list containing the page orientation of the PDF. |
Yes, see Configure the Set a Control's Properties Action for more information. |
Theme | A drop-down list containing the themes that you can use for the PDF file. | No |
Left Margin |
Sets the left margin of the PDF file in points and defaults to 72pt. One point is 1/72 of 1 inch. Specify numeric (1in) or point (72pt) values. |
Yes, see Configure the Set a Control's Properties Action for more information. |
Right Margin |
Sets the right margin of the PDF file in points and defaults to 72pt. One point is 1/72 of 1 inch. Specify numeric (1in) or point (72pt) values. |
Yes, see Configure the Set a Control's Properties Action for more information. |
Top Margin |
Sets the top margin of the PDF file in points and defaults to 72pt. One point is 1/72 of 1 inch. Specify numeric (1in) or point (72pt) values. |
Yes, see Configure the Set a Control's Properties Action for more information. |
Bottom Margin |
Sets the bottom margin of the PDF file in points and defaults to 72pt. One point is 1/72 of 1 inch. Specify numeric (1in) or point (72pt) values. |
Yes, see Configure the Set a Control's Properties Action for more information. |
Data Source | ||
SmartObject | The SmartObject to use when saving the PDF file. If you use a custom SmartObject, it should have a Create function, List method, a File Property, and a Number or Autonumber property (for the record ID). | No |
Method | The method to use to create the PDF file. Only Create functions are supported. | No |
File | The file type to use when creating the PDF file. | No |
Key Property | The unique identifier of the SmartObject to use when saving the PDF file. | No |
The control interacts with other controls through rules. When you bind properties between different controls, you can use the data to populate properties or set values. Use the following examples for when to use the control with other controls through rules:
- Set a control’s properties: You can configure the settable properties of the control with this action. For example, File Name if you need a unique name for each PDF file.
The following methods and events are available on the control:
Control Methods:
- Execute a control's Save PDF : This method executes synchronously. While executing the method, the browser is locked but the Key Property's value is immediately available. This method is useful when you need the Key Property's value in the same rule .
- Execute a control's Save PDF Async: This method executes asynchronously. While executing the method, the Key Property's value is not available. After execution of the method, the When [control] is Complete event is raised and the Key Property's value is available. This method is useful when you do not need the Key Property's value or you do not want to lock the browser.
When executing the control methods, the value of the control is set to the Key Property as configured in the SmartObject you configure as the data source of the control. You can map this value, for example, to a data field in a workflow and execute a Load method on the SmartObject to attach the PDF to an email. The Key Property is used to identify the record in the SmartObject used to store the PDF file. This should be generated during the execution of the SmartObject Create method and be unique. Using an Autonumber type is recommended if you're using a custom SmartObject.
Rule Events:
- When [control] is Complete: You can execute a rule condition or action after the PDF is created. This means the control is done executing one of its methods and its value is set to the new Key Property’s value. If you want to get the Key Property’s value and are using the Execute a control's Save PDF Async method, you must execute this event.
- When [control] is Started: You can execute a rule condition or action when the PDF is created. If you are changing values or the HTML of the page, you should wait until this event is raised to prevent any changes made to the form from being rendered in the PDF.
You can use these events after using the control methods. You can also configure an action to execute before or after the PDF is created. One example is where you use the Execute a control's Save PDF Async method and you want to add a label to the document before it is saved as a PDF file to indicate that it's a copy of the original document. You can configure the following rules to show the CopyLabel control before the PDF file is saved:
- The control is not a display control
- The control is also available when designing forms
- You can only create one PDF file per record
- When you use tabs on a form, all tabs are included as pages in the PDF file
- When you use a fixed width such as 1024px on a form containing the control, the PDF file may contain scroll bars. To fix this, change the Page Size of the control to a bigger size or adjust the Page Orientation. See the calculations below for the correct width to use with different page sizes:
Page Size Pixel/inch (control) Pixels (Form Width) A0 33,1 3178 A1 23,4 2246 A2 16,5 1584 A3 11,7 1123 A4 8,3 797 A5 5,8 557 A6 4,1 394 A7 2,9 278 A8 2 192 A9 1,5 144 A10 1 96 ArchA 9 864 ArchB 12 1152 ArchC 18 1728 ArchD 22 2112 ArchE 34 3264 B0 39,4 3782 B1 27,8 2669 B2 19,7 1891 B3 13,9 1334 B4 9,8 941 B5 6,9 662 Flsa 1,5 144 HalfLetter 8,5 816 Ledger 17 1632 Legal 8,5 816 Letter 8,5 816 11x17 11 1056 Note 7,5 720 - When you use a List view with a fixed width, the headers might not be aligned. Consider the following variables when you format the view or form:
- Save as PDF control: A2 Portrait
- Form Dimensions:
- Padding - (default) 12px
- Themes - All themes
- Border sizing - (default) 12px
- Form Width - 1560px
- When you use many tabs on a form or a List view with many columns, it is best to set the orientation to Landscape and the page size to A3 to render the PDF
- When you use the PDF File SmartObject to store the PDF file, it is important to clean up unused PDF files on a regular basis to ensure that you don't start having performance issues when loading PDF files. If you only require PDF files for the duration of a workflow, you can remove them manually once the workflow is complete.
- You can bind the control to a data source that is specifically used for document management, such as a SharePoint document Library when you create a large amount of PDF files
- It is important to use a valid SSL certificate in environments with an HTTPS URL. If the certificate is invalid or self-signed, the PDF may fail to convert the view or form, CSS style files may not be included, and images may not render in the PDF.
- Other scenarios where the PDF converter may fail are when there are various security restrictions on the computer or network, like the firewall blocking access to the Certificate Revocation List