Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cross-platform-pdf-generator

Package Overview
Dependencies
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cross-platform-pdf-generator - npm Package Compare versions

Comparing version 0.0.8 to 0.0.9

9

main.js
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;

}
*/
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc