[Client-side HTML to PDF] Can it be customized to custom layout with specific height and width of PDF?
client-side-html-to-pdf
Mobile icon
Forge component by Kilian Hekhuis
Application Type
Mobile

Hi,


I wanted to create a custom size of PDF with all the expressions filled with data but not really sure the way to do using this Forge. Is it possible to do so? From what I've understood on this Forge is that I need to pass the ContainerId which may include Form, sub-containers and etc and we can use the PdfBinaryGet to get the binary through the binary data. This is straightforward for me. 

But still, my concern is still on the custom layout/size of the Pdf. Since it's based on the screen of the device, I'm not sure where to set the width and height. Any advice would very much be appreciated.

Thanks,

Kenny

mvp_badge
MVP
Solution

Hi Kenny,

Currently the page size is hardcoded as A4, regardless of the screen size. Each Container (the intial one specified in PdfCreate as well as any additional ones you specify in PdfPageAdd) will be scaled to that page size.

Hi Kilian,

Thanks for your prompt response. Would have to explore more options out there then. Thanks again and have a nice day ahead!

mvp_badge
MVP

Hi Kenny,

If you can't find anything else that suits your needs, let me know. Adding more page size would probably not that difficult, but I didn't have a need to add it up till now.

Hello everybody,

I see that you have that issue for a long time, but as I only recently got involved in outsystems I just figured it out.

So for your request you just have to open the "Client-side HTML to PDF" module that you installed. Then in the scripts list you will find the 'jspdf_debug' javascript file. In this one, and specifically in the lines that you will see in the screenshot, you will find all the available page sizes along with their names. Now for the part the change of the page size, you have to open the 'PdfCreate' javascript file and in 347 code line you have to change the name 'a4' with the size name of the one you want. In case you want to add a custom sized page you have to create one in the first file. If you notice in my file i have the name "thermal-printer" as I want to create a thermal printer receipt. Hope I helped. If something is not clear just tell me.

Screenshot_1.png

mvp_badge
MVP

Hi Konstantinos,

It is in general not advised to change the content of a Forge component, as when you install a newer version, your changes will be overridden. With what you wrote I could check if I can add this to the component, so that there's no need for changing it yourself. Thanks for your help!

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.