I started this out, but be aware of limitations on text clarity. Next step is to convert the image to PDF. Not too hard, but gotta move on to some other things now.
If you look at what I did with my implementation, you can just use jsPDF to convert the image to a PDF file, and return it to an imageuploader / string in bubble.
I cant continue on it right now but feel free to collaborate on my preliminary implementation where it takes a bubble report page and creates an image.
Just tried the one on the link below and works great. The only problem is that I don´t know how to store it on the database so we can send with the email, also I don´t know how to change the filename and lastly the first time you click on the download button it does not load any data inside the PDF.
You are trying to use JAVA code (not javascript) in the message body. I don`t really understand why you are doing that. Also, the message body should not contain javascript either, only a JSON object (structured data).
Try the following.
Make sure your report page is visible for non-logged in users. You can make a “report” page which is public, and populating the data based on the URL data. Example. mybubbleapp.com/publicreportpage/?reportid=234345345345
Create a HTML block on the reportpage with the following code:
/**
html: HTML string to convert to PDF
savePdf: Callback for saving PDF
Opens the PDF in a new tab, and returns it as a data URI
*/
function pdfRocket(html, savePdf) {
var self = this;
self.save = savePdf;
self.req = new XMLHttpRequest();
// Additional parameters can be added here
var data = “apikey=” + apiKey + “&value=” + encodeURIComponent(html);
self.req.onload = function(event) {
self.reader = new FileReader();
self.reader.addEventListener("loadend", function() {
// Open in new tab
window.open(self.reader.result, "_blank");
// return data URI
return self.reader.result;
});
self.reader.readAsDataURL(self.req.response);
After it works you can make the report page secure in one of the following ways.
Either:
-Making sure that the reportpage only is available to be opened for XX minutes. Either by checking timestamp on page load. Plus running a scheduled workflow daily to delete all expired ones.
OR (if you need report to be available for a long time):
-require two datastrings to access the report a unique-id for the reportdata and a secret-key. Or just generate a long hash string. The good thing with using unique-id and secret-key is that you can detect when someone tries multiple times to access a report and you can mitigate further requests from same user.
– Note that using javascript means your API key will be visible and if you are worried about another HTML to PDF Rocket customer grabbing it and coding their own service, you should use a server side approach.
I haven´t achieved anything man and this code did not work for me (I´m pretty sure I need some knowledge to get this going and not a code problem). Thought that I was going to be capable of getting something working but it´s kind of difficult for me.
I think that the best way to go is joining forces together, hehe.
I suggest you use one of the third party PDF generators if this is too technical. They are pretty reasonable for pricing, number of generated PDFs. When Ive achieved a better approach I will let you know.
Hey Guys,
I used the code mentioned in the top post and it worked for me.
However, when i try to use a more recent version, i see this error on the preview page:
hi i have been struggling for days. does anybody know how to make just one page landscape? ive tried these and just cant get one page to be landscape they all turn
doc = new jsPDF();
{
doc.addPage(‘l’, ‘ls’, ‘a4’);
doc.addPage();