Apply Jspdf to this extension

579 views
Skip to first unread message

Jacob Gurr

unread,
Jan 16, 2021, 10:07:46 PM1/16/21
to Autofill Chrome Extension
Howdy, I think of the three potential methods to apply JSpdf to this extension:

import { jsPDF } from "jspdf";

or

insert the downloaded jspdf folder into this extension and add the <script>"jspdf.example"</script> code to options.html and then add the permission to manifest.json.

or

use jquery function and add the <script>"jspdf.example"</script> to the head html.

Neither of them worked for me. I feel like I missed something. Can anyone tell me what is it?

Autofill Chrome Extension

unread,
Jan 18, 2021, 4:51:37 PM1/18/21
to Autofill Chrome Extension
You should be able to use JS rule to inject  <script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.2/jspdf.min.js"></script>  into document. 

Jacob Gurr

unread,
Jan 18, 2021, 7:48:55 PM1/18/21
to Autofill Chrome Extension
Ok, so I have done this by far and it failed.

(function(d, script) {
    script = d.createElement('script');
    script.onload = function(){
        // remote script has loaded
    };
    d.getElementsByTagName('head')[0].appendChild(script);
}(document));

import { jsPDF } from "jspdf";

// Default export is a4 paper, portrait, using millimeters for units
const doc = new jsPDF();

doc.text("Hello world!", 10, 10);
doc.save("a4.pdf");

According to error: "Cannot use import statement outside a module"
I looked for some other ways to replace import method but I failed. Spent quite some time on this haha.

By the way, you helped me get closer to this achievement. Thank you so much

Autofill Chrome Extension

unread,
Jan 24, 2021, 12:39:49 AM1/24/21
to Autofill Chrome Extension
Hi Jacob,

Extensions do not support modules, so you'll have to read up on this plugin's documentation to see how to use it without relying on import statement.

Jacob Gurr

unread,
Feb 14, 2021, 4:50:08 PM2/14/21
to Autofill Chrome Extension
Thanks, I got it figured out to inject jspdf and html2pdf with this extension. :) Thank you so much for the extension again!

Autofill Chrome Extension

unread,
Feb 20, 2021, 2:42:40 PM2/20/21
to Autofill Chrome Extension
Awesome, glad you got it sorted out! ^^
Reply all
Reply to author
Forward
0 new messages