Ultimate PDF on ODC
"Ultimate PDF" is a widely used Forge Component that has been utilized in O11 environments.
It has an ODC-compliant one. Let's try it here.
A list of components
To-Do list
- What has the Chromium usage and location become
- Delve into the PrintLayout Block to see if I can create a screen working both as a standard screen and a form to be printed
- Look at the usage of Output Parameters from CurrEnvironment Action
Basic Usage
Install
Installing Ultimate PDF also makes UltimatePDF_ExternalLogic installed.
I installed Ultimate PDF 1.1.5, UltimatePDF_ExternalLogic 0.1.5, and Template_UltimatePDF 0.1.3.
The latter component is an External Logic.
Usage section of GitHub page
This is just a trial for me, so I added all elements from Ultimate PDF as references.
Create an empty screen
I made the screen accessible to Everyone. If we omit this setting, the output pdf is from the Login Screen. There seems to be a way to secure Screens without setting them as Everyone. I'll look at this later.
Add the PrintLayout Block to the screen
The PrintLayout Block has the following structure.
It contains Header, MainContent, and Footer Placeholders, so I guess we should place the Block in place of the existing Layout Block like this.
Build the report = Create a screen to be printed to a PDF
This is the structure of my sample screen.
1. the Layout Block for forms
We place this layout Block to create forms for PDFs.
Looking at the OnReady Action, this Block setup page and margin sizes.
2. Contents in this Block can only be seen on web pages (not in PDFs)
I added a button to create a PDF file and placed it inside a HideOnPrint block to hide the button on the PDF file.
3. Page Number Blocks
If the printed PDF file is composed of three pages and we look at the second page, we get "2/3" by putting these Patterns.
PageNumber Block / PageCount Block
Call the PrintToPDF Server Action
PrintToPDF Action from Ultimate PDF
By looking at ScreenToPDF_OnInitialize Action from Ultimate PDF, we can know what kinds of values should be set to Input Parameters.
URL: full path of the Screen
Environment: the Output Parameter of CurrEnvironment Client Action from Ultimate PDF
Here's a screenshot of the Downloaded PDF file.
Japanese Characters are not displayed. This is due to some font problems mentioned in the GitHub page.
Relevant insights and knowledge taken from this component
Client timezone
CurrEnvironment Action from Ultimate PDF Library returns the Client's timezone.
I found "Intl.DateTimeFormat.prototype.resolvedOptions()" on mdn page.
It's the first time for me to see this I/F, but the page is under "Standard built-in objects" of JavaScript Reference.
The description of timezone:
The value provided for this property in the options argument; defaults to the runtime's default time zone. Should never be undefined.
Font related topics
From Knwon Limitations,
The version of chromium bundle with the forge component only has Open Sans font installed meaning it only supports a subset of languages. As a workaround the customer can add the needed fonts as css (https://developers.google.com/fonts/docs/getting_started).
So, the problem of Japanese characters not being shown is probably caused by this.
By looking at the Fonts Static Entity, I found a font that seems to be a Japanese one.
I added OnInitialize Action and a call to the Style/SetDocumentFont Client Action from Ultimate PDF.
The result PDF:
We can successfully show Japanese Characters by this setting.
Template_UltimatePDF Usage
Create an App based on "Ultimate PDF" Template
memo
Following "Advance PDF Generation" section.
There is no description of Viewport property.
Downloaded files are 0 bytes..
When I tried opening the screen on my browser, It showed a blank screen for a few seconds. Maybe this is the cause of 0 bytes output.
When I called IsPDFTokenValid in OnInitialize of the form screen, there is an error "There was a problem. Please contact the administrator" shown on the printed PDF. If I accessed the screen through browser, there is no such error.
There was an error in DataAction. The cause was that I Generated a Token and called the External Logic Action in the same Action without calling CommitTransaction. When accessing the form Screen, created record including Generated Token had not been committed.
Version History
As of 2024/06/30, we can not follow version history back to past.
Release Notes from Version 1.1.8
Here are some changes that pulls my interest
Created a code wrapper to be able to call the external logic code in an AWS Lambda without using the OutSystems infrastructure
Does this mean that there is a way to call AWS Lambda created by an External Logic directly and this way is supported or at least tolerated?
I'll follow the C# code later.
Use normal browser mode instead of incognito
Removed ScreenToPDF functionality, due to changes in the OutSystems application runtime