Jspdf: Question: rendering a barcode in the PDF

Created on 1 Jan 2017  路  1Comment  路  Source: MrRio/jsPDF

I'm using this library to render a barcode in HTML, using JavaScript:
https://github.com/lindell/JsBarcode/

The rendered barcode is an html <svg> with <rect>'s in it

Any hints on how to add this barcode to my PDF using jsPDF ?
Will the html-to-pdf feature work?

Most helpful comment

Answer:

HTML:

    <canvas id="barcode"></canvas>

Javascript:

    JsBarcode("#barcode", "hello im a barcode");

    var jpegUrl = $("#barcode").toDataURL("image/jpeg");

    doc.addImage(jpegUrl, 'JPEG', 0, 0);

>All comments

Answer:

HTML:

    <canvas id="barcode"></canvas>

Javascript:

    JsBarcode("#barcode", "hello im a barcode");

    var jpegUrl = $("#barcode").toDataURL("image/jpeg");

    doc.addImage(jpegUrl, 'JPEG', 0, 0);
Was this page helpful?
0 / 5 - 0 ratings

Related issues

NoFootDancer picture NoFootDancer  路  3Comments

mellisa0109 picture mellisa0109  路  3Comments

allenksun picture allenksun  路  3Comments

sajesh1985 picture sajesh1985  路  5Comments

andmaltes picture andmaltes  路  4Comments