The code uses the jsPDF.js JavaScript library and an extension to work with Base64.
We will try to adapt the code without using the extension. [spoiler: currently not working]
I have used two methods, one with extension and the other without extension:
Method 1:
Image file to Base64 via JavaScript.
Convert content to PDF with jsPDF library.
Get a PDF in string Base64.
With extension KIO4_Base64 convert string Base64 to file pdf.
Works!
Method 2:
Image file to Base64 via JavaScript.
Convert content to PDF with jsPDF library.
Get a PDF in string Base64.
Using the JavaScript
atob command
we decode the Base64.
String to component
File.Save
No Works!
The problem is that atob doesn't decode the image well.
javascript_pdf1
702×550 70.4 KB
eval(content);
var returnOutput = doc.output('datauri');
// .split("base64,")[1]) to remove data:*;base64,
AppInventor.setWebViewString(returnOutput.split("base64,")[1]);
</script>
genpdf_atob.html
<script src="jspdf.min.js"></script>
<script>
var content = AppInventor.getWebViewString();
var doc = new jsPDF();
eval(content);
var returnOutput = doc.output('datauri');
// .split("base64,")[1]) to remove data:*;base64,
AppInventor.setWebViewString(atob(returnOutput.split("base64,")[1]));
</script>