How do you generate a pdf off line?

hello, i'm new in app inventor and i'm trying to figure out how to follow the info in this thread of the previuous forum:
https://groups.google.com/forum/#!topic/mitappinventortest/LK-WCVRFUA4

From what i understood i have to use some javascript code to make the trick, but what i cannot understand is if the js have to be loaded/stored somewhere OR have to be hardcoded in some "strings" of the block section :frowning:

There is an html file (containing the javascript) in the assets of the app. This remains static, no changes necessary (unless you want to…).

If you look in the blocks you will see the webviewstring being set. This is for demo purposes only, but is the place where you let your imagination run wild, and code accordingly.

As advised in that post, you will need to read up on the syntax for the two plugins (jspdf and jspdf-autotable)

ok thanks, but how to load the html in the app?
Is made from inside the app inventor web page or have to copy from pc to android phone via usb?

PS: is clear i’m a nub i’nt it? :smiley:

In the demo it all happens automagically when you click the button

i look better to the demo and i see there are genpdf.html jspdf.debug.js and jspdf.min.js in the “media” section :smiley:
i’ll do the same in my project.

I was fouled by the idea that “media” was only for images or other visual stuff :wink:

Thanks Tim for your support.
Analyzing your demo code i made a simple pdf, but now i have a problem.
I set an image on the pdf TOP, using the KIO4_base641.fileToString pointed to the logo_file, and this fires the KIO4_base641.GotString code (that gives commands to the js library).

So i replace the “pdf commands section” that was inside the KIO4_base641.GotString block with a separated procedure and i add 3 variables to store the “fileToString” calls of 3 separated KIO4 extensions

… so not the pdf generation was started by a button click that fires KIO4_base641.fileToString (for logo)-> KIO4_base642.fileToString (for the sign) -> generatePDF_procedure

and in that procedure i use the strings i store in the 2 variables.

1 Like

Best to show you blocks so we can see what you are up to…

how? that’s my project verifiche_v10.aia (434.6 KB)

For your immediate problem of creating a pdf, you have the call to “compilePDF” in the wrong place. You need to call it AFTER you have set the string like this:

You have additional issues with your app design and setup:

  1. You have crossed the 10 screen barrier - did you see the warning ?
  2. You are not switching screens correctly
    blocksSwitching
Use different screens wisely

If you decided to use different screens, then you should switch them correctly, else you will run out of memory after a while...      
The recommended method of switching screens in App Inventor
(Thanks Taifun)
 
Also see demo: multiscreen.aia
 

thanks, i’m new in ai2 so have to learn a lot of stuff …

opening a new screen every time was weird also for me but had not found the way to GO from a screen to another until now :wink:

still have problems with file path in my application, but i realized i miss a “;” in the jspdf “command” when adding the image, so now i can add the header logo and both signs at page bottom.

wheird think is that i can save the signs in the saveas method of the canvas with paths like that:
/DCIM/Camera/firmaispettore.jpg

i can delete the same images by command using the file delete method with paths like this:
/DCIM/Camera/firmaresponsabile.jpg

but cannot reload them back using the canvas set_backgroung_image method with the same path style: /DCIM/Camera/firmaispettore.jpg

so the trick is “not to miss the commas” in the jspdf commands :smiley:

Disculpa lograste terminar este proyecto me gustaria que me ayudaras resolver lo de la generacion del pdf con las 2 imagenes del canvas.

@allegfede espero una respuesa.
@TIMAI2 o si pudieras ayudarme para algo asi de este proyecto.

Follow this guide:

https://groups.google.com/g/mitappinventortest/c/LK-WCVRFUA4/m/Af_s-TVDBAAJ

Export (saveas) your canvas to an image
include your saved image in the pdf

@TIMAI2 mira ya genero un pdf con texto de un formulacion y capturo 2 firmas de las cuales se almacenan pero no tengo idea de como insertarlas el el documento PDF, pruebo algunos proyectos que estan en la guia que mandaste pero no me funcionan.

@TIMAI2 Si tuvieras algun ejemplo basico exportando una firma del canvas a un pdf me ayudarias mucho, me salvarias jeje.

https://puravidaapps.com/snippets.php#2canvassave

@TIMAI2 Me comentaron que tenia que pasarla a base64 y despues que el pdf la procese y la inserte en los ejemplos no mencionas algo de eso.

image

image

@TIMAI2 ok, lo probare, oye supiste si funciono el proyecto de allegfede.

Anyone who has much experience in java extension development can easily do.