Implemented pdf connect template. Updated pdf_example.png screenshot

This commit is contained in:
Glenn de Haan
2024-09-21 10:10:54 +02:00
parent 89ed5db429
commit 9cc7fe7cb5
3 changed files with 29 additions and 3 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 KiB

After

Width:  |  Height:  |  Size: 94 KiB

View File

@@ -10,6 +10,11 @@ const PrinterTypes = require('node-thermal-printer').types;
*/
const variables = require('./variables');
const log = require('./log');
const qr = require('./qr');
/**
* Import own utils
*/
const time = require('../utils/time');
const bytes = require('../utils/bytes');
const size = require('../utils/size');
@@ -25,7 +30,7 @@ module.exports = {
* @return {Promise<unknown>}
*/
pdf: (voucher) => {
return new Promise((resolve) => {
return new Promise(async (resolve) => {
const doc = new PDFDocument({
bufferPages: true,
size: [226.77165354330398, size(voucher)],
@@ -45,7 +50,6 @@ module.exports = {
});
doc.image('public/images/logo_grayscale_dark.png', 75, 15, {fit: [75, 75], align: 'center', valign: 'center'});
doc.moveDown(6);
doc.font('Helvetica-Bold')
@@ -61,6 +65,28 @@ module.exports = {
doc.moveDown(2);
doc.font('Helvetica')
.fontSize(10)
.text(`Connect to: `, {
continued: true
});
doc.font('Helvetica-Bold')
.fontSize(10)
.text(variables.unifiSsid, {
continued: true
});
doc.font('Helvetica')
.fontSize(10)
.text(` or,`);
doc.font('Helvetica')
.fontSize(10)
.text(`Scan to connect:`);
doc.image(await qr(), 75, 205, {fit: [75, 75], align: 'center', valign: 'center'});
doc.moveDown(6);
doc.moveDown(2);
doc.font('Helvetica-Bold')
.fontSize(12)
.text(`Voucher Details`);

View File

@@ -2,7 +2,7 @@
* Util function to calculate paper size based on voucher data
*/
module.exports = (voucher) => {
let base = 260;
let base = 375;
if(voucher.qos_usage_quota) {
base += 10;