229
Views
12
Comments
Solved
[PDF Generator Mobile] Any demo or guidance on PDF Generator Mobile
pdf-generator-mobile
Mobile icon
Forge asset by Reyco Seguma
Application Type
Mobile

Hi all, 


I wish to create a custom PDF through mobile devices locally but I'm having issues with setting the page layout. Most of the tools that I've found on Forge is not supporting the specific layout that I want. For this Forge, is there any demo that I can follow? Because we have the CreatePDF action that we can customize the PDF layout but how to insert the data into the PDF created from the action? We do have the textAppendData action as well for us to insert the text that we want. Another is that the PDFGetData. Based on my understanding, the steps needed to be taken are CreatePDF, textAppendData, PDFGetData, and convert the Output(text) to base64 to Binary for download? Correct me if I'm wrong here. 


Thanks,

Kenny

2025-04-02 05-41-45
Reyco Seguma
Solution

Hi Kenny,

Here's the flow for creating PDF.

Creating PDF
1. Add the Javacript library
- make sure you added this libraries on the block or screen you are using it to.


2. Initialize and set content for the PDF

3. Render the PDF (This generates the PDF)

4. Save the PDF on local device


Thank you

Reyco

2023-11-14 07-36-16
Yung Shin

Hi Reyco,


Thanks a lot! This is what I'm looking for. It is working as intended! Just want to add on, I tried to upload the image (converted from binary to base64 as required) in the imageAppendData client action and it doesn't work. Any advice on this?

Regards,

Kenny

2025-04-02 05-41-45
Reyco Seguma

Hi Kenny,

Make sure your Base64 data starts with something like this.

data:image/png;base64,(YourBase64 data here)

Example:

data:image/png;base64,iVBO832usadasd9asdasd9asd9as8das9dasdshjhas9dashk3jhkjsahd9asdhas

Thanks

2023-11-14 07-36-16
Yung Shin

Hi Reyco,

I did what you said in the previous reply,

I assigned another string in front of the output from converting binary to base64, but it seems like it still doesn't work. The image I've uploaded to the database previously is in JPG format. I've also tried changing the png to jpg to test it out but still doesn't work. Do enlighten me if I missed something around here. Thanks.

Regards,

Kenny

2025-04-02 05-41-45
Reyco Seguma

Try this..

data:image/jpeg;base64,iVBORw0KGgoA

just google the right format for viewing jpg, png etc.
Here's some reference
https://stackoverflow.com/questions/8499633/how-to-display-base64-images-in-html

Here's some sample of the converted Jpeg data and its usage.
use the data url format.

Make sure you converted the data correctly.
The forge component have BinaryToBase64 converter you can use it.

Thanks

2023-11-14 07-36-16
Yung Shin

Thanks, it seems like I need to convert the binary data from jpg to png to display it (Tried BinaryToBase64, and changing to jpeg doesn't work for me). Will do more test regarding this.


Regards,

Kenny 

2025-04-02 05-41-45
Reyco Seguma

Hi Yung Shin,

I think that might be the solution. Just convert everything to PNG to avoid anymore error.
I haven't upgraded the component yet. I might add this on the next version.

Thanks

2022-08-26 05-45-19
Jeremy Kuang

Thanks Reyco for a very useful Forge Component and this guide. Not sure if you is ok with this but what I did was that I modified part of PDF Generator's codes. I added a Structure Attribute called i_imageType to imageDataStruct to define the type of image that is being added

and then in the Javascript "create", I used an if else to determine whether to use pdfDoc.embedPng() or pdfDoc.embedJpg().

2018-05-28 09-56-50
Filipe Silva

Hi Kenny,

I have never used this component, but have you tried the demo on the forge component page?

2023-11-14 07-36-16
Yung Shin

Hi Filipe,


Thanks for informing regarding the demo, was never aware of the existence of that feature till now. I'll update with you again once I've tried out the Forge demo. Thanks again!


Regards,

Kenny

2025-04-02 05-41-45
Reyco Seguma
Solution

Hi Kenny,

Here's the flow for creating PDF.

Creating PDF
1. Add the Javacript library
- make sure you added this libraries on the block or screen you are using it to.


2. Initialize and set content for the PDF

3. Render the PDF (This generates the PDF)

4. Save the PDF on local device


Thank you

Reyco

2023-11-14 07-36-16
Yung Shin

Hi Reyco,


Thanks a lot! This is what I'm looking for. It is working as intended! Just want to add on, I tried to upload the image (converted from binary to base64 as required) in the imageAppendData client action and it doesn't work. Any advice on this?

Regards,

Kenny

2025-04-02 05-41-45
Reyco Seguma

Hi Kenny,

Make sure your Base64 data starts with something like this.

data:image/png;base64,(YourBase64 data here)

Example:

data:image/png;base64,iVBO832usadasd9asdasd9asd9as8das9dasdshjhas9dashk3jhkjsahd9asdhas

Thanks

2023-11-14 07-36-16
Yung Shin

Hi Reyco,

I did what you said in the previous reply,

I assigned another string in front of the output from converting binary to base64, but it seems like it still doesn't work. The image I've uploaded to the database previously is in JPG format. I've also tried changing the png to jpg to test it out but still doesn't work. Do enlighten me if I missed something around here. Thanks.

Regards,

Kenny

2025-04-02 05-41-45
Reyco Seguma

Try this..

data:image/jpeg;base64,iVBORw0KGgoA

just google the right format for viewing jpg, png etc.
Here's some reference
https://stackoverflow.com/questions/8499633/how-to-display-base64-images-in-html

Here's some sample of the converted Jpeg data and its usage.
use the data url format.

Make sure you converted the data correctly.
The forge component have BinaryToBase64 converter you can use it.

Thanks

2023-11-14 07-36-16
Yung Shin

Thanks, it seems like I need to convert the binary data from jpg to png to display it (Tried BinaryToBase64, and changing to jpeg doesn't work for me). Will do more test regarding this.


Regards,

Kenny 

2025-04-02 05-41-45
Reyco Seguma

Hi Yung Shin,

I think that might be the solution. Just convert everything to PNG to avoid anymore error.
I haven't upgraded the component yet. I might add this on the next version.

Thanks

2022-08-26 05-45-19
Jeremy Kuang

Thanks Reyco for a very useful Forge Component and this guide. Not sure if you is ok with this but what I did was that I modified part of PDF Generator's codes. I added a Structure Attribute called i_imageType to imageDataStruct to define the type of image that is being added

and then in the Javascript "create", I used an if else to determine whether to use pdfDoc.embedPng() or pdfDoc.embedJpg().

2025-04-02 05-41-45
Reyco Seguma

Hi Kenny,

Here's the flow for modifying PDF.

Modifying PDF

1. Add the Javacript library

- make sure you added this libraries on the block or screen you are using it to.


2. Initialize and Set Content

3. Modify PDF

4. Save PDF


Thank you

Reyco

2022-02-23 11-51-04
Vijay Bhaskar Reddy Palle

hi Yung Shin

please share the demo OML here,
it would be helpful to me.

Thanks & Regards,
vijay

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