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

bpmckee picture bpmckee  路  70Comments

abdullah9said picture abdullah9said  路  63Comments

doubletaketech picture doubletaketech  路  53Comments

vzhikness picture vzhikness  路  69Comments

diegocr picture diegocr  路  43Comments