Hi everyone,
for my app I need to generate a bill/ ticket in PDF taking the data from firebase.
Does anyone of you know a function ( or a third party service that allows to do that)?
I was thinking about creating a Template and filling it from the app.
I found this service that uses API but idk if it could suit my needs since i can’t really understand how it works.
Has there been any further investigation of this topic? I am wanting to do the same thing. I was looking at the link @domhnallohanlon provided, but I don’t know how to implement it. I would like to make a PDF from a google sheet or local table.
In summery (so I know what kind of YouTube videos to look up), how do I incorporate an app script with Thunkable? I found this in a Google Search. How to Print Google Sheet to PDF Using Apps Script - xFanatical Is this what I am looking for or does it need to be in a different format? I haven’t’ worked with this side of Thunkable before, but I would love to learn. I just need to know what questions to ask
if it can be done with HTML and javascrip
I’ve done it but the web view won’t let me download the PDF and I get stuck there
I’m going to look for the web I made so you can see it, I hope I haven’t deleted it
The idea is to make an app script inside the Google sheet and test it to see it works.
Next you need to publish the app script to the web. Once this is done, you will use the URL produced by publishing to web to call it from Thunkable.
As I said earlier, I have NOT tried it but this is the way it should be.
Why I’m saying this because I have my own HTML pages that I execute app scripts from the page using same method I explained above.
Thank you for that. So surprisingly, I was able to have some luck. I found and then modified a script that now returns the created pdf URL in the doGet() of the script. So now I have the script, how do I implement it into the app? Once I get a solid solution, I will share it.
Now you need to convert the doGet() to a URL by choosing “Publish to web” and then test the generated URL in a browser to see that the PDF file is generated.
The file does successfully generate. I was able to see and view it earlier because it is already published. The function doGet is called here: (and the exportSpreadsheet returns the sheet URL)
and I get this string in return with the Published web app (:
If I paste this link in the browser, it does bring me to the file.
When I paste the URL in Export PDF, it runs the script successfully and I get something like the link I posted earlier. With this info, what do I need to do to get it into something like a variable? The Thunkable Pull was the same project but as a API deployment. I didn’t know which one I needed.
Here is the .txt file of the script for what I have. Is this enough info? Sorry for all of the questions. This is the first time I have done this, and the documentation was not making sense. It is safe to assume that I have no idea what I am doing, and what I have gotten done this far was mostly from the git repo I found with the source code, a YouTube video which told me about the doGet(), and a basic understanding of programing to rearrange a few things and guess and check.
Now do it from a web viewer and make sure you get the file created. It is better to have the web viewer with default URL or no URL and have a button to assig this as the URL and see if it will create the file.
If it does (which it should) then your solution is already in production. You just need to tweak it for your requirements.
It does indeed create it. Is there a way to grab the string URL which displays at the end and return that to the app? That is what my end goal is, to get that string. My other question, is there a way to pass a variable to the script from the app?
Example: There is a variable for the sheetID in the script, so is there a way to through new values through parameters to that script? Therefore generating a new PDF?
Thank you for that. That would definitely work for me. I would also like to make something that is easy to use for everyone. I was looking into the WebViewer docs, and I found on the GitHub page this
<script type="text/javascript">
// when the button is clicked, send a message to the app
document.getElementById('messageButton').onclick = function() {
ThunkableWebviewerExtension.postMessage('hello world');
}
// when we get a message from the app, display it on the page
ThunkableWebviewerExtension.receiveMessage(function(message) {
document.getElementById('messageDisplay').innerHTML = message;
});
</script>
My thought process was to send a random message, and the received message would send back the URL. Am I able to use this in this way?
That will not be easy with Google App Script but it would still be doable should you want to take that route.
[Edit]
This is an example of the HTML extension for the Web Viewer. As you might be aware there is no block in Thunkable to compute dates, You cannot get the date in 17 days from today, for example. So I made an extension to use JavaScript to compute the date using the Web Viewer Extension.