Working with PDF files
Generating PDF files
UI Bakery allows you to generate PDF files from your Tables for reporting and other purposes. Let's review how you can do that.
To generate PDF:
Navigate to the Custom code tab and specify the following script:
Load the data you need and add a table to display it. (As an example, we'll use the table with user data.)
Create a new action of the JavaScript Code type and add the following code:
Please note that this code is exemplary and needs to be changed based on your table and necessary file structure.
Next, add the Button component to your working area that will download the generated file.
Assign your JavaScript Code action to the Button's component On Click trigger.
That's it! Now you will be able to download your Table data in the PDF format.
Downloading PDF with a JS code action
You can also use the following code in your JavaScript Code action to download a PDF file:
After running the action, the file will be downloaded automatically to your default Downloads folder.
Printing PDF files
Now that you've generated your PDF file, you can also print it directly from the app. Let's review how you can do that.
To print PDF:
Add the File picker component to your working area.
Next, connect the Print.js library in the Custom Code tab using the following script:
Create a JavaScript Code action and specify the following code:
Now, select the file you want to print in the File picker component and execute the action from step 3.
A Print window will appear where you can choose your printing options and proceed to printing the file.
Last updated
Was this helpful?