Socket
Socket
Sign inDemoInstall

swissqrbill

Package Overview
Dependencies
73
Maintainers
1
Versions
66
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.2.0 to 3.2.1

8

lib/browser/esm/pdf/pdf.js

@@ -394,8 +394,5 @@ import { ExtendedPDF } from "./extended-pdf.js";

_renderQRCode() {
const qrcode = generateQRCode(this._data, utils.mm2pt(46));
const qrcode = generateQRCode(this._data, "pdf", utils.mm2pt(67), this._marginTop + utils.mm2pt(17), utils.mm2pt(46));
//-- Add QR Code
this.addPath(qrcode, utils.mm2pt(67), this._marginTop + utils.mm2pt(17))
.undash()
.fillColor("black")
.fill();
this.addContent(qrcode).fillColor("black").fill();
//-- Add Swiss Cross

@@ -405,2 +402,3 @@ const swissCrossBackground = "M18.3 0.7L1.6 0.7 0.7 0.7 0.7 1.6 0.7 18.3 0.7 19.1 1.6 19.1 18.3 19.1 19.1 19.1 19.1 18.3 19.1 1.6 19.1 0.7Z";

this.addPath(swissCrossBackground, utils.mm2pt(86.5), this._marginTop + utils.mm2pt(36))
.undash()
.fillColor("black")

@@ -407,0 +405,0 @@ .lineWidth(1.42)

import { Data } from "./types";
export default function generateQRCode(data: Data, size: number): string;
export default function generateQRCode(data: Data, type: "pdf" | "svg", xOrigin: number, yOrigin: number, size: number): string;
import { getReferenceType } from "../shared/utils.js";
import { qrcodegen } from "./qr-code-generator.js";
export default function generateQRCode(data, size) {
/**
* Limits the maximum and minimum number possible according to the PDF specifications.
* Borrowed from: https://github.com/foliojs/pdfkit/blob/120c3f9519e49d719a88d22d70139cc9f54d17d8/lib/object.js#L123-L130
*/
function limitNumber(n) {
if (n > -1e21 && n < 1e21) {
return Math.round(n * 1e6) / 1e6;
}
throw new Error(`unsupported number: ${n}`);
}
export default function generateQRCode(data, type, xOrigin, yOrigin, size) {
var _a;

@@ -151,3 +161,3 @@ let qrString = "";

const segments = qrcodegen.QrSegment.makeSegments(qrString);
const qrCode = qrcodegen.QrCode.encodeSegments([eci, ...segments], qrcodegen.QrCode.Ecc.MEDIUM);
const qrCode = qrcodegen.QrCode.encodeSegments([eci, ...segments], qrcodegen.QrCode.Ecc.MEDIUM, 10, 25);
const blockSize = size / qrCode.size;

@@ -160,3 +170,10 @@ const parts = [];

if (qrCode.getModule(x, y)) {
parts.push(`M ${xPos}, ${yPos} V ${yPos + blockSize} H ${xPos + blockSize} V ${yPos} H ${xPos} Z `);
switch (type) {
case "pdf":
parts.push(`${limitNumber(xOrigin + xPos)} ${limitNumber(yOrigin + yPos)} ${limitNumber(blockSize)} ${limitNumber(blockSize)} re`);
break;
case "svg":
parts.push(`M ${xPos}, ${yPos} V ${yPos + blockSize} H ${xPos + blockSize} V ${yPos} H ${xPos} Z `);
break;
}
}

@@ -163,0 +180,0 @@ }

@@ -125,3 +125,3 @@ import { validateData, cleanData } from "../shared/shared.js";

else {
//- Add rectangle
//-- Add rectangle
receiptTextContainer.addTSpan(translations[this._language].payableByName)

@@ -399,3 +399,3 @@ .x(0)

_renderQRCode() {
const qrcode = generateQRCode(this._data, utils.mm2px(46));
const qrcode = generateQRCode(this._data, "svg", 0, 0, utils.mm2px(46));
const qrcodeSVG = this.instance.addSVG("46mm", "46mm")

@@ -402,0 +402,0 @@ .y("17mm")

@@ -423,8 +423,5 @@ "use strict";

_renderQRCode() {
const qrcode = (0, qr_code_js_1.default)(this._data, utils.mm2pt(46));
const qrcode = (0, qr_code_js_1.default)(this._data, "pdf", utils.mm2pt(67), this._marginTop + utils.mm2pt(17), utils.mm2pt(46));
//-- Add QR Code
this.addPath(qrcode, utils.mm2pt(67), this._marginTop + utils.mm2pt(17))
.undash()
.fillColor("black")
.fill();
this.addContent(qrcode).fillColor("black").fill();
//-- Add Swiss Cross

@@ -434,2 +431,3 @@ const swissCrossBackground = "M18.3 0.7L1.6 0.7 0.7 0.7 0.7 1.6 0.7 18.3 0.7 19.1 1.6 19.1 18.3 19.1 19.1 19.1 19.1 18.3 19.1 1.6 19.1 0.7Z";

this.addPath(swissCrossBackground, utils.mm2pt(86.5), this._marginTop + utils.mm2pt(36))
.undash()
.fillColor("black")

@@ -436,0 +434,0 @@ .lineWidth(1.42)

import { Data } from "./types";
export default function generateQRCode(data: Data, size: number): string;
export default function generateQRCode(data: Data, type: "pdf" | "svg", xOrigin: number, yOrigin: number, size: number): string;

@@ -5,3 +5,13 @@ "use strict";

const qr_code_generator_js_1 = require("./qr-code-generator.js");
function generateQRCode(data, size) {
/**
* Limits the maximum and minimum number possible according to the PDF specifications.
* Borrowed from: https://github.com/foliojs/pdfkit/blob/120c3f9519e49d719a88d22d70139cc9f54d17d8/lib/object.js#L123-L130
*/
function limitNumber(n) {
if (n > -1e21 && n < 1e21) {
return Math.round(n * 1e6) / 1e6;
}
throw new Error(`unsupported number: ${n}`);
}
function generateQRCode(data, type, xOrigin, yOrigin, size) {
var _a;

@@ -154,3 +164,3 @@ let qrString = "";

const segments = qr_code_generator_js_1.qrcodegen.QrSegment.makeSegments(qrString);
const qrCode = qr_code_generator_js_1.qrcodegen.QrCode.encodeSegments([eci, ...segments], qr_code_generator_js_1.qrcodegen.QrCode.Ecc.MEDIUM);
const qrCode = qr_code_generator_js_1.qrcodegen.QrCode.encodeSegments([eci, ...segments], qr_code_generator_js_1.qrcodegen.QrCode.Ecc.MEDIUM, 10, 25);
const blockSize = size / qrCode.size;

@@ -163,3 +173,10 @@ const parts = [];

if (qrCode.getModule(x, y)) {
parts.push(`M ${xPos}, ${yPos} V ${yPos + blockSize} H ${xPos + blockSize} V ${yPos} H ${xPos} Z `);
switch (type) {
case "pdf":
parts.push(`${limitNumber(xOrigin + xPos)} ${limitNumber(yOrigin + yPos)} ${limitNumber(blockSize)} ${limitNumber(blockSize)} re`);
break;
case "svg":
parts.push(`M ${xPos}, ${yPos} V ${yPos + blockSize} H ${xPos + blockSize} V ${yPos} H ${xPos} Z `);
break;
}
}

@@ -166,0 +183,0 @@ }

@@ -154,3 +154,3 @@ "use strict";

else {
//- Add rectangle
//-- Add rectangle
receiptTextContainer.addTSpan(translations_js_1.default[this._language].payableByName)

@@ -428,3 +428,3 @@ .x(0)

_renderQRCode() {
const qrcode = (0, qr_code_js_1.default)(this._data, utils.mm2px(46));
const qrcode = (0, qr_code_js_1.default)(this._data, "svg", 0, 0, utils.mm2px(46));
const qrcodeSVG = this.instance.addSVG("46mm", "46mm")

@@ -431,0 +431,0 @@ .y("17mm")

@@ -394,8 +394,5 @@ import { ExtendedPDF } from "./extended-pdf.js";

_renderQRCode() {
const qrcode = generateQRCode(this._data, utils.mm2pt(46));
const qrcode = generateQRCode(this._data, "pdf", utils.mm2pt(67), this._marginTop + utils.mm2pt(17), utils.mm2pt(46));
//-- Add QR Code
this.addPath(qrcode, utils.mm2pt(67), this._marginTop + utils.mm2pt(17))
.undash()
.fillColor("black")
.fill();
this.addContent(qrcode).fillColor("black").fill();
//-- Add Swiss Cross

@@ -405,2 +402,3 @@ const swissCrossBackground = "M18.3 0.7L1.6 0.7 0.7 0.7 0.7 1.6 0.7 18.3 0.7 19.1 1.6 19.1 18.3 19.1 19.1 19.1 19.1 18.3 19.1 1.6 19.1 0.7Z";

this.addPath(swissCrossBackground, utils.mm2pt(86.5), this._marginTop + utils.mm2pt(36))
.undash()
.fillColor("black")

@@ -407,0 +405,0 @@ .lineWidth(1.42)

import { Data } from "./types";
export default function generateQRCode(data: Data, size: number): string;
export default function generateQRCode(data: Data, type: "pdf" | "svg", xOrigin: number, yOrigin: number, size: number): string;
import { getReferenceType } from "../shared/utils.js";
import { qrcodegen } from "./qr-code-generator.js";
export default function generateQRCode(data, size) {
/**
* Limits the maximum and minimum number possible according to the PDF specifications.
* Borrowed from: https://github.com/foliojs/pdfkit/blob/120c3f9519e49d719a88d22d70139cc9f54d17d8/lib/object.js#L123-L130
*/
function limitNumber(n) {
if (n > -1e21 && n < 1e21) {
return Math.round(n * 1e6) / 1e6;
}
throw new Error(`unsupported number: ${n}`);
}
export default function generateQRCode(data, type, xOrigin, yOrigin, size) {
var _a;

@@ -151,3 +161,3 @@ let qrString = "";

const segments = qrcodegen.QrSegment.makeSegments(qrString);
const qrCode = qrcodegen.QrCode.encodeSegments([eci, ...segments], qrcodegen.QrCode.Ecc.MEDIUM);
const qrCode = qrcodegen.QrCode.encodeSegments([eci, ...segments], qrcodegen.QrCode.Ecc.MEDIUM, 10, 25);
const blockSize = size / qrCode.size;

@@ -160,3 +170,10 @@ const parts = [];

if (qrCode.getModule(x, y)) {
parts.push(`M ${xPos}, ${yPos} V ${yPos + blockSize} H ${xPos + blockSize} V ${yPos} H ${xPos} Z `);
switch (type) {
case "pdf":
parts.push(`${limitNumber(xOrigin + xPos)} ${limitNumber(yOrigin + yPos)} ${limitNumber(blockSize)} ${limitNumber(blockSize)} re`);
break;
case "svg":
parts.push(`M ${xPos}, ${yPos} V ${yPos + blockSize} H ${xPos + blockSize} V ${yPos} H ${xPos} Z `);
break;
}
}

@@ -163,0 +180,0 @@ }

@@ -125,3 +125,3 @@ import { validateData, cleanData } from "../shared/shared.js";

else {
//- Add rectangle
//-- Add rectangle
receiptTextContainer.addTSpan(translations[this._language].payableByName)

@@ -399,3 +399,3 @@ .x(0)

_renderQRCode() {
const qrcode = generateQRCode(this._data, utils.mm2px(46));
const qrcode = generateQRCode(this._data, "svg", 0, 0, utils.mm2px(46));
const qrcodeSVG = this.instance.addSVG("46mm", "46mm")

@@ -402,0 +402,0 @@ .y("17mm")

{
"name": "swissqrbill",
"version": "3.2.0",
"version": "3.2.1",
"description": "Swiss QR Bill generation in Node.js and browsers",

@@ -152,8 +152,8 @@ "main": "./lib/node/cjs/node/index.js",

"devDependencies": {
"@schoero/eslint-config": "^1.4.0",
"@schoero/eslint-config": "^1.6.1",
"@types/blob-stream": "^0.1.30",
"@types/node": "^17.0.21",
"@types/node": "^18.7.14",
"@types/svg-parser": "^2.0.3",
"@typescript-eslint/eslint-plugin": "^5.13.0",
"@typescript-eslint/parser": "^5.13.0",
"@typescript-eslint/eslint-plugin": "^5.36.1",
"@typescript-eslint/parser": "^5.36.1",
"assert": "^2.0.0",

@@ -163,14 +163,14 @@ "brfs": "^2.0.2",

"buffer": "^6.0.3",
"eslint": "^8.10.0",
"eslint": "^8.23.0",
"process": "^0.11.10",
"readable-stream": "^3.6.0",
"transform-loader": "^0.2.4",
"ts-loader": "^9.2.7",
"typescript": "^4.6.2",
"ts-loader": "^9.3.1",
"typescript": "^4.8.2",
"util": "^0.12.4",
"webpack": "^5.70.0",
"webpack-cli": "^4.9.2"
"webpack": "^5.74.0",
"webpack-cli": "^4.10.0"
},
"dependencies": {
"@types/pdfkit": "^0.12.3",
"@types/pdfkit": "^0.12.6",
"blob-stream": "^0.1.3",

@@ -177,0 +177,0 @@ "pdfkit": "^0.13.0",

@@ -42,3 +42,2 @@ <div align="center">

<br/>

@@ -49,25 +48,25 @@ <br/>

* [Features](#features)
* [Installation](#installation)
* [Importing the library](#importing-the-library)
* [Quick start](#quick-start)
* [Browser usage](#browser-usage)
* [API documentation](https://github.com/schoero/SwissQRBill/blob/master/doc/api.md)
* [PDFKit documentation](http://pdfkit.org/docs/getting_started.html)
* [How to create a complete bill](https://github.com/schoero/SwissQRBill/blob/master/doc/how-to-create-a-complete-bill.md)
* [QR bill validator](https://swiss-qr-invoice.org/validator/?lang=de)
* [QR bill specifications](https://www.paymentstandards.ch/dam/downloads/ig-qr-bill-en.pdf)
* [Features](#features)
* [Installation](#installation)
* [Importing the library](#importing-the-library)
* [Quick start](#quick-start)
* [Browser usage](#browser-usage)
* [API documentation](https://github.com/schoero/SwissQRBill/blob/master/doc/api.md)
* [PDFKit documentation](http://pdfkit.org/docs/getting_started.html)
* [How to create a complete bill](https://github.com/schoero/SwissQRBill/blob/master/doc/how-to-create-a-complete-bill.md)
* [QR bill validator](https://swiss-qr-invoice.org/validator/?lang=de)
* [QR bill specifications](https://www.paymentstandards.ch/dam/downloads/ig-qr-bill-en.pdf)
<br/>
## Features
- Generate complete invoices, or only the QR Bill, as a PDF file.
- Generate the QR Bill as a scalable vector graphic (SVG).
- Works in browsers and Node.js.
- Supports german, english, italian and french invoices.
- Allows you to add other content above the invoice using [PDFKit](https://github.com/foliojs/pdfkit).
- Easy to use.
- Free and open source.
* Generate complete invoices, or only the QR Bill, as a PDF file.
* Generate the QR Bill as a scalable vector graphic (SVG).
* Works in browsers and Node.js.
* Supports german, english, italian and french invoices.
* Allows you to add other content above the invoice using [PDFKit](https://github.com/foliojs/pdfkit).
* Easy to use.
* Free and open source.
<br/>

@@ -107,3 +106,14 @@

Unfortunately, The [current version of TypeScript](https://github.com/microsoft/TypeScript/issues/46452) and Node.js prior to v12.16.0 or v13.6.0, do not support this feature.
Be aware that TypeScript versions prior to v4.7.0 and Node.js prior to v12.16.0 or v13.6.0, do not support this feature.
To get conditional exports to work with TypeScript > v4.7.0, you have to set these two options your `tsconfig.json`:
```json
{
"compilerOptions": {
"module": "ESNext",
"moduleResolution": "NodeNext"
}
}
```
If you are using a TypeScript or Node.js version that doesn't support the new export feature, you can still take advantage of tree-shaking, by importing the files directly by their path.

@@ -124,3 +134,3 @@

```html
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/swissqrbill/lib/browser/bundle/index.js" />
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/swissqrbill/lib/browser/bundle/index.js"></script>
```

@@ -135,5 +145,4 @@

However, if you want to take advantage of tree-shaking in the browser, you have to bundle the library by yourself.
You can find an example, how this could be done using webpack, at https://github.com/schoero/SwissQRBill-browser-example.
You can find an example, how this could be done using webpack, at <https://github.com/schoero/SwissQRBill-browser-example>.
<br/>

@@ -212,2 +221,3 @@ <br/>

```
<br/>

@@ -223,2 +233,2 @@ <br/>

[<img src="https://raw.githubusercontent.com/schoero/SwissQRBill/master/assets/complete-qr-bill.png">](https://github.com/schoero/SwissQRBill/tree/master/doc/how-to-create-a-complete-bill.md)
[<img src="https://raw.githubusercontent.com/schoero/SwissQRBill/master/assets/complete-qr-bill.png">](https://github.com/schoero/SwissQRBill/tree/master/doc/how-to-create-a-complete-bill.md)

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc