cross-platform-pdf-generator
Advanced tools
Comparing version 1.1.5 to 1.1.6
{ | ||
"name": "cross-platform-pdf-generator", | ||
"version": "1.1.5", | ||
"version": "1.1.6", | ||
"description": "pulsation pdg generator for web and ios", | ||
@@ -5,0 +5,0 @@ "main": "main.js", |
@@ -35,3 +35,3 @@ import { PDFDocument, StandardFonts, rgb, PDFFont, PDFPage, PDFTextField } from 'pdf-lib'; | ||
const initInsets = Object.assign( | ||
let initInsets = Object.assign( | ||
{ | ||
@@ -60,2 +60,12 @@ "page": 0, | ||
//If PDF has custom draw offset use this | ||
const templateTextOffset = getTextContainer() | ||
if (templateTextOffset) { | ||
const box = getBoxFor(templateTextOffset) | ||
initInsets = { | ||
"page": 0, | ||
"y": box.y | ||
} | ||
} | ||
//handle forms | ||
@@ -73,6 +83,6 @@ | ||
await printFooter(pdfDoc, json); | ||
}catch (e) { | ||
} catch (e) { | ||
return e.message; | ||
} | ||
const pdfBytes = await pdfDoc.save(); | ||
@@ -88,3 +98,3 @@ return pdfBytes; | ||
await printFooter(pdfDoc, json); | ||
}catch (e) { | ||
} catch (e) { | ||
return e.message; | ||
@@ -107,3 +117,3 @@ } | ||
if (value?.value === undefined) continue; | ||
unhandeld = unhandeld.filter(e => e.title !== name && e.id !== name); | ||
unhandeld = unhandeld.filter(e => e.title !== name && e.id !== name); | ||
await drawTextInField(value, field, document); | ||
@@ -115,2 +125,13 @@ } | ||
function getTextContainer(fields) { | ||
let hit | ||
fields.forEach(field => { | ||
const name = field.getName() | ||
if (field === "TEXT_START") { | ||
hit = field | ||
} | ||
}) | ||
return hit | ||
} | ||
export function cleanData(data) { | ||
@@ -120,5 +141,5 @@ if (!Array.isArray(data)) return data | ||
let maxIndex = data.length-1 | ||
let maxIndex = data.length - 1 | ||
for(let i = 0; i<data.length; i++) { | ||
for (let i = 0; i < data.length; i++) { | ||
let object = data[i] | ||
@@ -130,6 +151,6 @@ | ||
textIndex = i + 2 | ||
}else if (object.type === "subSection") { | ||
} else if (object.type === "subSection") { | ||
textIndex = i + 1 | ||
}else { | ||
} else { | ||
cleaned.push(object) | ||
@@ -225,5 +246,5 @@ continue | ||
if (value?.component === "toggle") { | ||
if (value.value === "Ja") {form.setText("X"); return} | ||
if (value.value === "Ja") { form.setText("X"); return } | ||
form.setText(""); | ||
}else { | ||
} else { | ||
form.setText(value.value); | ||
@@ -454,3 +475,3 @@ } | ||
values.forEach(v => { | ||
flatResult.push({ type: v?.type ?? "unknown", title: v?.title, value: v?.value, id: v?.id, component: v?.component}); | ||
flatResult.push({ type: v?.type ?? "unknown", title: v?.title, value: v?.value, id: v?.id, component: v?.component }); | ||
}) | ||
@@ -482,3 +503,3 @@ }) | ||
jpegImage = baseIMG; | ||
}catch { | ||
} catch { | ||
jpegImage = null; | ||
@@ -490,5 +511,5 @@ } | ||
printFooterOnPage(page, document, jpegImage, i, font, | ||
json?.documentSettings?.footerText, | ||
json?.documentSettings?.footerVersion, | ||
json?.environment); | ||
json?.documentSettings?.footerText, | ||
json?.documentSettings?.footerVersion, | ||
json?.environment); | ||
i++; | ||
@@ -568,5 +589,5 @@ }); | ||
versionText = "Version: " + process.env.npm_package_version; | ||
}else if (typeof version === "string") { | ||
} else if (typeof version === "string") { | ||
versionText = "Version: " + version; | ||
}else { | ||
} else { | ||
versionText = "Unbekannte Version"; | ||
@@ -573,0 +594,0 @@ } |
@@ -190,3 +190,3 @@ import { GenericStorage } from "./utils/GenericUtils/GenericStorage.js"; | ||
if (value === undefined) return; | ||
if (value.isRemoved === 1) return | ||
if (value.isRemoved) return | ||
if (r?.is_not_printable ?? false) return; //do not print value | ||
@@ -193,0 +193,0 @@ const valueToPrint = value?.humanReadableDescription ?? "Ungültiger Wert im Druck" |
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
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
67542
1589