cross-platform-pdf-generator
Advanced tools
Comparing version 0.0.8 to 0.0.9
import { createPDFFromJSON } from "./PrintService.js"; | ||
import { createPrintOrder, getPrintInstruction, prepairPrintData } from "./StorageInterpreter.js"; | ||
import fs from 'fs'; | ||
//import fs from 'fs'; | ||
//import values from "./PDFtemplates/values.json"; | ||
@@ -14,4 +14,4 @@ //import { runDemo } from './StorageInterpreter.js'; | ||
*/ | ||
export async function printServiceCreatePDFFromJSON(json) { | ||
return await createPDFFromJSON(json); | ||
export async function printServiceCreatePDFFromJSON(json, template) { | ||
return await createPDFFromJSON(json, template); | ||
} | ||
@@ -80,3 +80,3 @@ | ||
/* | ||
function saveFile(name, bytes) { | ||
@@ -94,4 +94,5 @@ return new Promise((resolve, rejects) => { | ||
} | ||
*/ | ||
//const bytes = await runDemo(values); | ||
//await saveFile("test", bytes); |
{ | ||
"name": "cross-platform-pdf-generator", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"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 fs from 'fs'; | ||
//import fs from 'fs'; | ||
@@ -10,6 +10,4 @@ /** | ||
*/ | ||
export async function createPDFFromJSON(json) { | ||
export async function createPDFFromJSON(json, template) { | ||
const template = loadTemplate(json?.documentSettings?.templateName); | ||
const pdfBytes = await generatePDFFile(template, json) | ||
@@ -426,10 +424,10 @@ | ||
const font = await document.embedFont(StandardFonts.Helvetica); | ||
const img = await loadFile("./ressources/pulsation.png"); | ||
//const img = await loadFile("./ressources/pulsation.png"); | ||
//create PDF Img | ||
const jpgImage = await document.embedPng(img); | ||
//const jpgImage = await document.embedPng(img); | ||
let i = 1; | ||
pages.forEach(page => { | ||
printFooterOnPage(page, document, jpgImage, i, font, json?.documentSettings?.footerText); | ||
printFooterOnPage(page, document, null, i, font, json?.documentSettings?.footerText); | ||
i++; | ||
@@ -465,15 +463,18 @@ }); | ||
const imgWidth = 70; | ||
const imgHeight = imgWidth / (img.width / img.height); | ||
if (img !== null) { | ||
const imgWidth = 70; | ||
const imgHeight = imgWidth / (img.width / img.height); | ||
const imgY = (footerBox.size.height * 0.5) - (imgHeight * 0.5); | ||
const imgY = (footerBox.size.height * 0.5) - (imgHeight * 0.5); | ||
page.drawImage(img, { | ||
x: footerBox.origin.x, | ||
y: imgY + (versionHeight * 0.5), | ||
width: imgWidth, | ||
height: imgHeight | ||
}); | ||
page.drawImage(img, { | ||
x: footerBox.origin.x, | ||
y: imgY + (versionHeight * 0.5), | ||
width: imgWidth, | ||
height: imgHeight | ||
}); | ||
} | ||
//print customText | ||
@@ -539,2 +540,3 @@ | ||
/* | ||
async function loadFile(path) { | ||
@@ -551,3 +553,5 @@ return new Promise((resolve, reject) => { | ||
} | ||
*/ | ||
/* | ||
function loadTemplate(name) { | ||
@@ -558,1 +562,3 @@ if (!typeof name === "string") return null; | ||
} | ||
*/ |
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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
719923
8108
1