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
Hi Kenny,Here's the flow for creating PDF.Creating PDF1. Add the Javacript library- make sure you added this libraries on the block or screen you are using it to.
3. Render the PDF (This generates the PDF)
4. Save the PDF on local deviceThank youReyco
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,
Hi Kenny,Make sure your Base64 data starts with something like this.data:image/png;base64,(YourBase64 data here)Example:
data:image/png;base64,iVBO832usadasd9asdasd9asd9as8das9dasdshjhas9dashk3jhkjsahd9asdhasThanks
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.
Try this..
data:image/jpeg;base64,iVBORw0KGgoA
just google the right format for viewing jpg, png etc.Here's some referencehttps://stackoverflow.com/questions/8499633/how-to-display-base64-images-in-htmlHere'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
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.
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
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().
Hi Kenny,
I have never used this component, but have you tried the demo on the forge component page?
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!
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 youReyco
hi Yung Shin
please share the demo OML here,it would be helpful to me.Thanks & Regards,vijay