cross-platform-pdf-generator
Advanced tools
Comparing version 0.1.7 to 0.1.8
{ | ||
"name": "cross-platform-pdf-generator", | ||
"version": "0.1.7", | ||
"version": "0.1.8", | ||
"description": "pulsation pdg generator for web and ios", | ||
@@ -5,0 +5,0 @@ "main": "main.js", |
import { PDFDocument, StandardFonts, rgb, PDFFont, PDFPage, PDFTextField } from 'pdf-lib'; | ||
import { Box } from "./utils/Box.js"; | ||
import Img from "./ressources/img.json"; | ||
@@ -55,8 +54,5 @@ /** | ||
const pdfDoc = await PDFDocument.load(template); | ||
const font = await pdfDoc.embedFont(StandardFonts.Helvetica); | ||
const pages = pdfDoc.getPages(); | ||
const firstPage = pages[initInsets.page]; | ||
const { width, height } = firstPage.getSize(); | ||
const form = pdfDoc.getForm(); | ||
const fields = form.getFields(); | ||
@@ -177,3 +173,2 @@ | ||
}); | ||
console.log("done"); | ||
@@ -444,3 +439,6 @@ } | ||
pages.forEach(page => { | ||
printFooterOnPage(page, document, pngImage, i, font, json?.documentSettings?.footerText); | ||
printFooterOnPage(page, document, pngImage, i, font, | ||
json?.documentSettings?.footerText, | ||
json?.documentSettings?.footerVersion, | ||
json?.environment); | ||
i++; | ||
@@ -451,3 +449,3 @@ }); | ||
function printFooterOnPage(page, document, img, pageNumber, font, customText) { | ||
function printFooterOnPage(page, document, img, pageNumber, font, customText, version, env) { | ||
if (!(document instanceof PDFDocument)) return; | ||
@@ -518,9 +516,11 @@ if (!(page instanceof PDFPage)) return; | ||
//print generator version | ||
let versionText | ||
if (env === "node") { | ||
versionText = "Version: " + process.env.npm_package_version; | ||
}else if (typeof version === "string") { | ||
versionText = "Version: " + version; | ||
}else { | ||
versionText = "Unbekannte Version"; | ||
} | ||
/*Just works in node environment | ||
const versionText = "Version: " + process.env.npm_package_version; | ||
*/ | ||
const versionText = "Version: " + "0.1.7"; | ||
page.drawText( | ||
@@ -559,24 +559,1 @@ versionText, | ||
} | ||
/* | ||
async function loadFile(path) { | ||
return new Promise((resolve, reject) => { | ||
fs.readFile(path, function (err, data) { | ||
if (err) { | ||
reject(err); | ||
} else { | ||
resolve(data); | ||
} | ||
}); | ||
}); | ||
} | ||
*/ | ||
/* | ||
function loadTemplate(name) { | ||
if (!typeof name === "string") return null; | ||
const uint8Array = fs.readFileSync('./PDFtemplates/' + name) ?? null; | ||
return uint8Array; | ||
} | ||
*/ |
import { GenericStorage } from "./utils/GenericUtils/GenericStorage.js"; | ||
import { GenericViewRepresentation, GenericRow, GenericSection } from "./utils/GenericUtils/GenericView.js"; | ||
//just demo | ||
import Data from './ressources/demoViews/demoData/data.json'; | ||
import Geb from './ressources/demoViews/Gebäude.json'; | ||
import F01 from './ressources/demoViews/F01 Brandmeldeanlage.json'; | ||
import Dienst from './ressources/demoViews/Andere Dienste.json'; | ||
import Abb from './ressources/demoViews/Abrechnung, Bemerkungen & Einsatzabschnitte.json'; | ||
import EinsAbb from './ressources/demoViews/Einsatzabschnitt.json'; | ||
import Schul from './ressources/demoViews/Gebührenschuldner.json'; | ||
import { createPDFFromJSON } from "./PrintService.js"; | ||
@@ -24,9 +15,10 @@ import { getValueFromStorage } from "./utils/GenericUtils/GenericStorageManager.js"; | ||
return { | ||
"environment": "node", // is value != "node", some node features are disabled | ||
"documentSettings": { | ||
"templateName": "", | ||
"footer": false, | ||
"footerPNG": "", | ||
"footerPNG": "", //set footer img as base64 encoded String | ||
"footerText": "", | ||
"footerVersion": "0.0.0", // is environment == node this is not used (package version will print on footer) | ||
"textSettings": { | ||
"valueSpacing": 8, | ||
"valueSpacing": 8, //Spacing between each value | ||
"fontSize": 11, | ||
@@ -37,4 +29,4 @@ "lineHeight": 1.4 | ||
"initDrawInset": { | ||
"page": 0, | ||
"y": 183 | ||
"page": 0, //page to start floating drawing | ||
"y": 183 //first drawing offset - | ||
}, | ||
@@ -49,4 +41,4 @@ | ||
}, | ||
"textSections": [], | ||
"otherValues": [] | ||
"textSections": [], //values to print | ||
"otherValues": [] //values to print | ||
} | ||
@@ -252,3 +244,3 @@ } | ||
/* | ||
export async function runDemo() { | ||
@@ -266,1 +258,2 @@ const rootViews = [Geb, F01, Abb, Dienst]; | ||
} | ||
*/ |
@@ -1,2 +0,2 @@ | ||
import { GenericRow, GenericSection, GenericViewRepresentation, GenericValidation, GenericRowStorage, GenericDependencyValidation } from "./GenericView.js"; | ||
import { GenericRow, GenericSection, GenericViewRepresentation, GenericDependencyValidation } from "./GenericView.js"; | ||
import { generateUUIDFrom } from "./GenericHelper.js"; | ||
@@ -3,0 +3,0 @@ |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
65583
11
1531
1
1