How to create PDF file in less than 5 min using Javascript

แชร์
ฝัง
  • เผยแพร่เมื่อ 26 ส.ค. 2021
  • In this video you will see how to create a PDF invoice template in less than 5 minutes, using my Javascript library named "jspdf-invoice-template".
    You will find it in npmjs or the source code in github:
    - www.npmjs.com/package/jspdf-i...
    - github.com/edisonneza/jspdf-i...
    Play with it:
    - edisonneza.github.io/jspdf-in...
    **Sorry for my wild dog. I couldn't stop him 😣
    Any Star or Contribution to the package is welcome!
    Thank you!
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 84

  • @naziruadam3950
    @naziruadam3950 ปีที่แล้ว +7

    I tested many examples and watched many tutorials, but yours is the one that actually worked for me. Also, when I visited the npm website, I could find the unpkg and the example links. I had to type the URL in your example in the address bar manually to get it. The updated version on the website doesn't give such an in-depth sample, or at least I could find where it was. Thanks for the tut.

    • @edisonneza
      @edisonneza  ปีที่แล้ว

      Thanks man! Glad it helped you!

  • @ionalexandrustefan1909
    @ionalexandrustefan1909 3 หลายเดือนก่อน

    Thank you for the help!

  • @krawzi4254
    @krawzi4254 หลายเดือนก่อน

    the only tutorial that worked, thank you!

    • @edisonneza
      @edisonneza  หลายเดือนก่อน

      Glad it helped you!

  • @Dr.UdaraSenarathne
    @Dr.UdaraSenarathne ปีที่แล้ว

    Thank you very much!

  • @Akephalos204
    @Akephalos204 2 ปีที่แล้ว

    Nice !!!!!!! And thanks

  • @Kolhv
    @Kolhv ปีที่แล้ว

    Thank you so much! Question, how would I add a custom "product" without the Array.from(Array(10), (item, index) => [] thing to the table?

    • @edisonneza
      @edisonneza  ปีที่แล้ว +2

      Hi, just create an array or use an array object filled with the products. Example: [{id: zxy, name: xyz, …etc}]

    • @mohamedaakhil
      @mohamedaakhil ปีที่แล้ว +2

      dumbahh

    • @SubcribeWithoutanyvideo-mt4zz
      @SubcribeWithoutanyvideo-mt4zz 11 หลายเดือนก่อน

      @@mohamedaakhil yooo

  • @user-vn7su2dj5o
    @user-vn7su2dj5o 3 หลายเดือนก่อน

    How can I generate pdf directly without using button? is there any solution where I can directly generate pdf & save in folder using jquery?

  • @steilebriese759
    @steilebriese759 ปีที่แล้ว

    thanks!

  • @brianochieng6982
    @brianochieng6982 2 ปีที่แล้ว

    how can i do this with vue.js , as i call data from an SQL Database . Because when i load the data into console it fetches but i dont know how to put it in a receipt

    • @edisonneza
      @edisonneza  2 ปีที่แล้ว

      Map the response you get to the props object for the pdf template library. Take a look at the readme file in order to understand better. Feel free to create an issue with more detailed info so I can help you specifically.

  • @mrwho7382
    @mrwho7382 2 ปีที่แล้ว

    THANK YOU SIR YOU ARE A GENIUS... I WAS STUCK ALMOST 2 WEEKS TRYING TO GENERATE MY INVOICE ... NOW FINALLY I FINISH.... DO YOU KNOW HOW CAN I DO INSTEAD OF DOWNLOAD... RENDER IN A NEW BROWSER WINDOW ?

    • @edisonneza
      @edisonneza  2 ปีที่แล้ว +1

      Thank you man, glad that it helped you!
      About your question, u can see the output object here:
      github.com/edisonneza/jspdf-invoice-template/blob/main/src/index.js
      Specifically what u need is this output type: dataurlnewwindow

    • @mrwho7382
      @mrwho7382 2 ปีที่แล้ว

      @@edisonneza Thanks man, how can I open in new window but with custom sizes lika a popup...i was trying using window.open()...

    • @edisonneza
      @edisonneza  2 ปีที่แล้ว +1

      @@mrwho7382 I think you can output it as a blob type and try to open it in a new browser windows with custom size passing it as a blob URL.
      Just a sample:
      stackoverflow.com/questions/21729451/pdf-blob-pop-up-window-not-showing-content

  • @sorknerl
    @sorknerl ปีที่แล้ว

    Is it possible to style the table with CSS? And how do I add simple text above the table?

    • @edisonneza
      @edisonneza  ปีที่แล้ว

      For the moment you can’t do that. If u want to add something that is not implemented in the template, just fork the projekt and make the specific things

    • @ImJuned09
      @ImJuned09 ปีที่แล้ว

      Use inline css it should work

  • @megasusmegajos4321
    @megasusmegajos4321 ปีที่แล้ว

    How can i change table cells style ? Like First row and first column to be bold or font 14 .

    • @edisonneza
      @edisonneza  ปีที่แล้ว

      For the moment is supported just the width style for header cells.
      Please open an issue on Github so i will try to add it as soon as i can.

  • @emanuel81111
    @emanuel81111 ปีที่แล้ว

    Thank you so much , this is 1000x better than all those fucking libraries like dinkToPDF or ironPDF , those fucking libraries takes hours to set it up and you have to do so much esoteric coding for it to work ,its so fucking annoying, but this way is the best

    • @edisonneza
      @edisonneza  ปีที่แล้ว

      😂😂 for basic usage you are right my friend

  • @oldaricopigon4225
    @oldaricopigon4225 8 หลายเดือนก่อน

    thanks

  • @rayanx95
    @rayanx95 ปีที่แล้ว

    I tried to change the logo src but I couldn't every time i changed it, the generator stopped working. any solution?

    • @edisonneza
      @edisonneza  ปีที่แล้ว

      Any console error? Create a github issue please with the error message

  • @brianevans4
    @brianevans4 ปีที่แล้ว +1

    Uses invoice template. Not generally applicable to creating pdfs

  • @eliya3424
    @eliya3424 3 หลายเดือนก่อน

    Love it!
    What is the best way to populate each row with info taken from user input? I created a Point-Of-Sale page that allows the user to select an item, specify qty and price, then add to cart. I have all the data stored in an array and use that array to dynamically update the cart display on the page. Can I use that array to populate the invoice rows?
    I can upload the link to my github repo.

    • @edisonneza
      @edisonneza  3 หลายเดือนก่อน

      Yes, exactly. For sure you can store are the needed info in a array of object and then just pass it to the object parameter of the template.

    • @edisonneza
      @edisonneza  3 หลายเดือนก่อน

      If any trouble you can send the url

  • @sanjitthakuri4381
    @sanjitthakuri4381 ปีที่แล้ว

    It downloads pdf in our system yes, but how can i send the generated PDF (from html) into backend server without downloading

    • @edisonneza
      @edisonneza  ปีที่แล้ว

      This is a question done even before. Please check the other comments and/or the GitHub issues. You will find the solution i think by sending the blob to the server and saving it in your server storage.

  • @alexanamelean
    @alexanamelean ปีที่แล้ว

    Hello, sorry for my bad english. I have tried to place an array (var customers = ;
    Array.from(customers).forEach(function(customer) {
    console.log([customer.Amount_kg,
    customer.Description,
    customer.Price_unit_kg,
    customer.Amount_kg,
    customer.Total_$,
    customer.Total_BsD,]);
    });) in the table field of the template and for more attempts, it does not work. could you help me?

    • @edisonneza
      @edisonneza  ปีที่แล้ว

      Seems to be too little info. Can you please show the error you get in the console? Are u sure you are properly converting the php result into a correct array? For more please create a new github issue for this kind of error by providing more info. Thanks!

  • @98cintya
    @98cintya 2 ปีที่แล้ว

    how can i center the title header? thanks

    • @edisonneza
      @edisonneza  ปีที่แล้ว

      At the moment it’s not possible. Working in a feature like this.

  • @chunchun_zip
    @chunchun_zip ปีที่แล้ว

    is there any way to run this, because the function doesn't work on me(via cdn link)

    • @edisonneza
      @edisonneza  ปีที่แล้ว

      Are u sure u have setup correcty? Can u send us an example? Or better create a github issue?

    • @chunchun_zip
      @chunchun_zip ปีที่แล้ว +1

      @@edisonneza oh I already fixed the issue thanks btw

  • @emilianovillarreal1744
    @emilianovillarreal1744 ปีที่แล้ว

    Hi! I've been running into the following error: Error: Incomplete or corrupt PNG file. Does anyone know how to fix that???

    • @edisonneza
      @edisonneza  ปีที่แล้ว +1

      Please open an github issue with reproducible steps.

  • @themanwithaharmonica9328
    @themanwithaharmonica9328 ปีที่แล้ว

    Do you have any idea how I can get the pdf document to support arabic?

    • @edisonneza
      @edisonneza  ปีที่แล้ว +1

      I’m sorry, for the moment can’t be possible. I have tried some methods but seems that jsPDF library isn’t supporting either.

    • @themanwithaharmonica9328
      @themanwithaharmonica9328 ปีที่แล้ว

      @eNeza Okay, thank you regardless

  • @TheRealHiro
    @TheRealHiro 10 หลายเดือนก่อน

    hello, im having issues, the total at the bottom is not showing for me. i followed every step on your code

    • @edisonneza
      @edisonneza  10 หลายเดือนก่อน

      Hello, to fix it i would need the parameters object you have created. Maybe you can open a github issue about this.

    • @TheRealHiro
      @TheRealHiro 10 หลายเดือนก่อน

      @@edisonneza im sorry, i used the old version, newest version worked

  • @remmanemohamed7120
    @remmanemohamed7120 2 ปีที่แล้ว

    Great video but How I can the change the size and the data inside the table using external variables

    • @edisonneza
      @edisonneza  2 ปีที่แล้ว

      Sorry man, i don't get it. Can you be more specific?

    • @remmanemohamed7120
      @remmanemohamed7120 2 ปีที่แล้ว

      I mean when I try to put a my variables inside the object like it will give me undefine

    • @edisonneza
      @edisonneza  2 ปีที่แล้ว +1

      ​@@remmanemohamed7120 a bit strange. Are you sure your variables are defined? Be careful for case sensitive variables. Let me know if still error.

    • @remmanemohamed7120
      @remmanemohamed7120 2 ปีที่แล้ว

      @@edisonneza no I fixed the error thank you for your intention

    • @juancampos13
      @juancampos13 ปีที่แล้ว

      @@remmanemohamed7120 Could you please tell me how did you fix it? When I try to put my external variables it shows me the UNDEFINED as well and I been trying to fix it but I don´t really know how to do it.

  • @rudikpoghosyan4776
    @rudikpoghosyan4776 ปีที่แล้ว

    How can I put my own variables

    • @edisonneza
      @edisonneza  ปีที่แล้ว

      In the props objects, instead of hard coding values, try to replace them with your variables!

  • @user-uv9kv4jo6s
    @user-uv9kv4jo6s 8 หลายเดือนก่อน

    How can I add Arabic text to the invoice

    • @edisonneza
      @edisonneza  8 หลายเดือนก่อน

      For the moment it is not possible for Arabic language. It’s related to the jpdf library.

  • @LeticiaS-Dev
    @LeticiaS-Dev 10 หลายเดือนก่อน

    how can i change the logo?

    • @edisonneza
      @edisonneza  3 หลายเดือนก่อน

      Change it in the params object

  • @domesan.u1610
    @domesan.u1610 หลายเดือนก่อน

    Brother what if I want to do this without using html how to do it?

    • @edisonneza
      @edisonneza  หลายเดือนก่อน

      What do you mean without using html? You want to include it in a react/angular code? If yes, just install the package from npm and import it.
      Anyway asap, i will publish a video on that as well.

    • @domesan.u1610
      @domesan.u1610 หลายเดือนก่อน

      @@edisonneza without html means i am doing content script for creating extension. So I cant insert scripts into webpages but also i need external libraries which have to be imported how to do?

    • @edisonneza
      @edisonneza  หลายเดือนก่อน

      @@domesan.u1610 if the script is in javascript/typescript you can import it. Open a github issue pls, providing some code examples, so i can help you;

  • @zanispleve1777
    @zanispleve1777 ปีที่แล้ว

    Where did you created template?

    • @edisonneza
      @edisonneza  ปีที่แล้ว

      Olympus Mons 😉

    • @zanispleve1777
      @zanispleve1777 ปีที่แล้ว

      @@edisonneza it founds only volcano on mars 😀

    • @edisonneza
      @edisonneza  ปีที่แล้ว

      @@zanispleve1777 😂😂 I didn’t get the question

    • @zanispleve1777
      @zanispleve1777 ปีที่แล้ว

      @@edisonneza So this template are great. But i want to create my template. Do you know where to create it?

    • @edisonneza
      @edisonneza  ปีที่แล้ว

      @@zanispleve1777 it’s a bit tricky to explain here, but you can see a video tutorial or read any blog post about it. Or see the code i have in the main branch and try to replicate it.

  • @kacperkepinski4990
    @kacperkepinski4990 ปีที่แล้ว

    generate from what...

    • @edisonneza
      @edisonneza  ปีที่แล้ว

      From whatever you want :D

  • @carlogarcenila8040
    @carlogarcenila8040 2 ปีที่แล้ว

    HI HOW CAN I PUT MY HTML IN INVOICE 2021

    • @carlogarcenila8040
      @carlogarcenila8040 2 ปีที่แล้ว

      ONLY THIS ARE WORKING logo: {
      src: "raw.githubusercontent.com/edisonneza/jspdf-invoice-template/demo/images/logo.png",
      type: 'PNG', //optional, when src= data:uri (nodejs case)
      width: 53.33, //aspect ratio = width/height
      height: 26.66,
      margin: {
      top: 0, //negative or positive num, from the current position
      left: 0 //negative or positive num, from the current position
      }
      },
      HOW CAN I PUT MY STYLE AND DIV AND CONTENT

    • @edisonneza
      @edisonneza  2 ปีที่แล้ว +1

      Unfortunately you cannot work with html in this template.

  • @jdhirhe
    @jdhirhe ปีที่แล้ว

    Not working for hindi font

    • @edisonneza
      @edisonneza  ปีที่แล้ว

      You’re right. There is a problem with some fonts with special chars. Have to make a lot o checks and tests in order to fix it.

  • @aretisrihari6878
    @aretisrihari6878 2 ปีที่แล้ว

    Does it support Arabic language ?

    • @edisonneza
      @edisonneza  2 ปีที่แล้ว

      Unfortunately it doesn't work. I have tried some ways but it will show just some chars. It's an issue with the jspdf library.

  • @jeancomontoya8715
    @jeancomontoya8715 5 หลายเดือนก่อน

    Can I ask something?

    • @edisonneza
      @edisonneza  5 หลายเดือนก่อน

      You could have done it 😊