cross-platform-pdf-generator
Advanced tools
Comparing version 1.0.1 to 1.0.2
{ | ||
"name": "cross-platform-pdf-generator", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "pulsation pdg generator for web and ios", | ||
@@ -5,0 +5,0 @@ "main": "main.js", |
@@ -63,2 +63,5 @@ import { PDFDocument, StandardFonts, rgb, PDFFont, PDFPage, PDFTextField } from 'pdf-lib'; | ||
//Clean and remove emty section from Data | ||
data = cleanData(data) | ||
//handle floating text | ||
@@ -99,5 +102,6 @@ | ||
const name = field.getName(); | ||
const value = data.find(v => v.title === name); | ||
const dataID = data?.id | ||
const value = data.find(v => v.title === name || v.title === dataID); | ||
if (value?.value === undefined) continue; | ||
unhandeld = unhandeld.filter(e => name !== e.title); | ||
unhandeld = unhandeld.filter(e => name !== e.title && dataID !== e.title); | ||
await drawTextInField(value, field, document); | ||
@@ -109,2 +113,30 @@ } | ||
export function cleanData(data) { | ||
if (!Array.isArray(data)) return data | ||
let cleaned = [] | ||
let maxIndex = data.length-1 | ||
for(let i = 0; i<data.length; i++) { | ||
let object = data[i] | ||
let textIndex = 0 | ||
if (object.type === "section") { | ||
textIndex = i + 2 | ||
}else if (object.type === "subSection") { | ||
textIndex = i + 1 | ||
}else { | ||
cleaned.push(object) | ||
continue | ||
} | ||
if (textIndex > maxIndex) continue | ||
if (data[textIndex].type !== "text") continue | ||
cleaned.push(object) | ||
} | ||
return cleaned | ||
} | ||
async function fillPDFDocument(document, page, values, insets, initInsets, settings) { | ||
@@ -111,0 +143,0 @@ if (!(document instanceof PDFDocument) || !Array.isArray(values)) return; |
import { GenericStorage } from "./utils/GenericUtils/GenericStorage.js"; | ||
import { GenericViewRepresentation, GenericRow, GenericSection } from "./utils/GenericUtils/GenericView.js"; | ||
import { createPDFFromJSON } from "./PrintService.js"; | ||
import { cleanData, createPDFFromJSON } from "./PrintService.js"; | ||
import { getValueFromStorage } from "./utils/GenericUtils/GenericStorageManager.js"; | ||
@@ -197,2 +197,3 @@ import { generateGVR, generateRoot } from "./utils/GenericUtils/MultinavigationManager.js"; | ||
{ | ||
"id": r.row_id, | ||
"type": "text", | ||
@@ -199,0 +200,0 @@ "title": rowName, |
import { sha256 } from 'js-sha256'; | ||
import ByteBuffer from "bytebuffer"; | ||
@@ -11,7 +10,4 @@ export function generateUUIDFrom(string) { | ||
let buffer = new ByteBuffer(); | ||
buffer.writeCString(uuidSeed, 0); | ||
const hash = sha256.array(uuidSeed); | ||
const hash = sha256.array(buffer.buffer.slice(0, byteCount)); | ||
const truncateBytes = hash.slice(0, 16); | ||
@@ -18,0 +14,0 @@ |
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
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
66724
1563
0