npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

pdf417-canvas

v1.0.5

Published

PDF417 HUB3 2D barcode generator for browser and Node

Downloads

78

Readme

PDF417 HUB3 Barcode Generator

This library provides you with the ability to generate PDF417 HUB3 Barcodes in browser or Node.js apps. The final barcode is drawn into a canvas element and can be used for many different use cases. The code is based on the bcmath-js and pdf417-js.

Browser

You can find a complete example at examples/browser and a running demo here.

The usage is as simple as providing a canvas element and a text that should be used for barcode generation:

<script src="https://cdn.jsdelivr.net/gh/pkoretic/pdf417-generator@master/lib/libbcmath.js" type="text/javascript"></script>
<script src="https://cdn.jsdelivr.net/gh/pkoretic/pdf417-generator@master/lib/bcmath.js" type="text/javascript"></script>
<script src="https://cdn.jsdelivr.net/gh/pkoretic/pdf417-generator@master/lib/pdf417.js" type="text/javascript"></script>

HTML

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

JS

var code = "HRVHUB30\nHRK\n" +
"000000000012355\n"+
"PETAR KORETIĆ\n"+
"PREVOJ DD\n"+
"10000 Zagreb\n"+
"pkoretic J.D.O.O\n"+
"PREVOJ DD\n"+
"10000 ZAGREB\n"+
"HR5041240000000000\n"+
"HR01\n"+
"7336-68949637625-00001\n"+
"COST\n"+
"Uplata za 1. mjesec\n";

var canvas = document.getElementById("barcode")
PDF417.draw(code, canvas)

Node.js

You can find a complete example at examples/node.

The node-canvas library is used for drawing.

Install the library:

npm install pdf417-generator

Use it as:

const Canvas = require("canvas")
const PDF417 = require("pdf417-generator")

const code =
`HRVHUB30
HRK
000000000012355
PETAR KORETIĆ
PREVOJ DD
10000 Zagreb
FIRMA J.D.O.O
PREVOJ DD
10000 ZAGREB
HR5041240000000000
HR01
7336-68949637625-00001
COST
Uplata za 1. mjesec`

let canvas = new Canvas()
PDF417.draw(code, canvas)

// create an image which can be sent in an e-mail or similar
console.log(`<img src="${canvas.toDataURL()}" />`)

TypeScript

import * as PDF417 from 'pdf417-generator';

PDF417.draw(code, canvas);

draw arguments

code - (string) code to represent using PDF417

canvas - (Canvas) Canvas instance

aspectRatio - (float) the width to height of the symbol (excluding quiet zones); default 2

ecl - (int) error correction level (0-8); default -1 = automatic correction level

devicePixelRatio (int) determine how much extra pixel density should be added to allow for a sharper image; default window.devicePixelRatio if available