mirror of
https://github.com/glenndehaan/unifi-voucher-site.git
synced 2026-03-31 06:24:00 -04:00
Implemented pdf connect template. Updated pdf_example.png screenshot
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 68 KiB After Width: | Height: | Size: 94 KiB |
@@ -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`);
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user