How to download a bill(a grid)i create using my one page website

check a codepen link:

try to add some quantities so they can appear on a grid way down the page.
suggestions, please.

Not sure I understand the question. Do you want the user to be able to download the ā€œbillā€ (or whatever it is) part of the page?

One option is to create a print button and have print-specific CSS that that will remove the rest of the page and only show the ā€œorder formā€.

There are print libraries as well (random lib from google search).

1 Like

This is for printing, itā€™s helpful.
How ever i want the user to be able to download a copy of that bill to his phone as pdf or even as an image of that bill, so he/she can be able to send it via WhatsApp or email.

Just search for it, you will find native APIs and libraries like html2canvas.

Example article

I found the jsPdf library, installed it but since the videos i found shows how different file names for each library, i couldnā€™t figure out which js library file i should put in the src of the script tag in the html head.
The video shows jspdf.min.js , but in my library there is no file in it with that exact name so i lost the lead there.
So close, but Didnā€™t work.

I donā€™t know what video you are talking about but I would suggest you read the docs for the lib.

That is exactly the video i watched, MrRio video.
In his video, he seems to to put src equals to a js file that i dont have in the dist folder.

Any way thank you.//////////////

so i thought i should share this:
the library is installed trough npm, I did what the doc said, and readme file, they basically say the say thing: here the code and a snap of the code and the page loaded with the link that will execute the pdf save:

<html>
  <head>
    <script src="https://unpkg.com/jspdf@latest/dist/jspdf.min.js"></script>
    <script type='text/javascript'>
        import { jsPDF } from "jspdf";

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

          doc.text("Hello world!", 10, 10);
          doc.save("a4.pdf");
        }
        
    </script>
  </head>
  <style>
  </style>
  
  <body>
    <a href='javascript:test()'>link</a>
      <script>


      </script>
  </body>
</html>

point me the mistake I have done.
question, how is it that we have e an import expression without exporting anything and the first place, or even including the type=ā€˜moduleā€™ in the script tag like the FCC reached us?

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.