Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
c5bc354f65 | |||
c48bb0428f | |||
46fbb615a0 | |||
3df4e103f9 |
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@push.rocks/smartpdf",
|
"name": "@push.rocks/smartpdf",
|
||||||
"version": "3.1.4",
|
"version": "3.1.6",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "A library for creating PDFs dynamically from HTML or websites with additional features like merging PDFs.",
|
"description": "A library for creating PDFs dynamically from HTML or websites with additional features like merging PDFs.",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
@ -34,7 +34,7 @@
|
|||||||
"@types/express": "^4.17.21",
|
"@types/express": "^4.17.21",
|
||||||
"express": "^4.19.2",
|
"express": "^4.19.2",
|
||||||
"pdf-lib": "^1.17.1",
|
"pdf-lib": "^1.17.1",
|
||||||
"pdf2json": "^3.0.5",
|
"pdf2json": "3.0.5",
|
||||||
"pdf2pic": "^3.1.1"
|
"pdf2pic": "^3.1.1"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
|
12
pnpm-lock.yaml
generated
12
pnpm-lock.yaml
generated
@ -15,7 +15,7 @@ dependencies:
|
|||||||
specifier: ^11.0.14
|
specifier: ^11.0.14
|
||||||
version: 11.0.14
|
version: 11.0.14
|
||||||
'@push.rocks/smartnetwork':
|
'@push.rocks/smartnetwork':
|
||||||
specifier: ^3.0.2
|
specifier: ^3.0.0
|
||||||
version: 3.0.2
|
version: 3.0.2
|
||||||
'@push.rocks/smartpath':
|
'@push.rocks/smartpath':
|
||||||
specifier: ^5.0.18
|
specifier: ^5.0.18
|
||||||
@ -42,7 +42,7 @@ dependencies:
|
|||||||
specifier: ^1.17.1
|
specifier: ^1.17.1
|
||||||
version: 1.17.1
|
version: 1.17.1
|
||||||
pdf2json:
|
pdf2json:
|
||||||
specifier: ^3.0.5
|
specifier: 3.0.5
|
||||||
version: 3.0.5
|
version: 3.0.5
|
||||||
pdf2pic:
|
pdf2pic:
|
||||||
specifier: ^3.1.1
|
specifier: ^3.1.1
|
||||||
@ -50,16 +50,16 @@ dependencies:
|
|||||||
|
|
||||||
devDependencies:
|
devDependencies:
|
||||||
'@git.zone/tsbuild':
|
'@git.zone/tsbuild':
|
||||||
specifier: ^2.1.72
|
specifier: ^2.1.66
|
||||||
version: 2.1.72
|
version: 2.1.72
|
||||||
'@git.zone/tsdoc':
|
'@git.zone/tsdoc':
|
||||||
specifier: ^1.1.27
|
specifier: ^1.1.12
|
||||||
version: 1.1.27
|
version: 1.1.27
|
||||||
'@git.zone/tsrun':
|
'@git.zone/tsrun':
|
||||||
specifier: ^1.2.46
|
specifier: ^1.2.44
|
||||||
version: 1.2.46(@types/node@20.12.7)
|
version: 1.2.46(@types/node@20.12.7)
|
||||||
'@git.zone/tstest':
|
'@git.zone/tstest':
|
||||||
specifier: ^1.0.90
|
specifier: ^1.0.77
|
||||||
version: 1.0.90(@types/node@20.12.7)
|
version: 1.0.90(@types/node@20.12.7)
|
||||||
'@push.rocks/tapbundle':
|
'@push.rocks/tapbundle':
|
||||||
specifier: ^5.0.23
|
specifier: ^5.0.23
|
||||||
|
@ -55,8 +55,8 @@ tap.test('should merge pdfs', async () => {
|
|||||||
|
|
||||||
tap.test('should create images from an pdf', async () => {
|
tap.test('should create images from an pdf', async () => {
|
||||||
const pdfObject = await testSmartPdf.readFileToPdfObject('.nogit/combined.pdf');
|
const pdfObject = await testSmartPdf.readFileToPdfObject('.nogit/combined.pdf');
|
||||||
const images = await testSmartPdf.convertPDFToJPGBytes(pdfObject.buffer);
|
const images = await testSmartPdf.convertPDFToPngBytes(pdfObject.buffer);
|
||||||
console.log(images);
|
console.log(images.map((val) => val.length));
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('should be able to close properly', async () => {
|
tap.test('should be able to close properly', async () => {
|
||||||
|
@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@push.rocks/smartpdf',
|
name: '@push.rocks/smartpdf',
|
||||||
version: '3.1.4',
|
version: '3.1.6',
|
||||||
description: 'A library for creating PDFs dynamically from HTML or websites with additional features like merging PDFs.'
|
description: 'A library for creating PDFs dynamically from HTML or websites with additional features like merging PDFs.'
|
||||||
}
|
}
|
||||||
|
@ -225,7 +225,7 @@ export class SmartPdf {
|
|||||||
return deferred.promise;
|
return deferred.promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async convertPDFToJPGBytes(
|
public async convertPDFToPngBytes(
|
||||||
pdfBytes: Uint8Array,
|
pdfBytes: Uint8Array,
|
||||||
options: {
|
options: {
|
||||||
width?: number;
|
width?: number;
|
||||||
@ -240,7 +240,7 @@ export class SmartPdf {
|
|||||||
|
|
||||||
const converter = plugins.pdf2pic.fromBuffer(Buffer.from(pdfBytes), {
|
const converter = plugins.pdf2pic.fromBuffer(Buffer.from(pdfBytes), {
|
||||||
density: 100, // Image density (DPI)
|
density: 100, // Image density (DPI)
|
||||||
format: 'jpg', // Image format
|
format: 'png', // Image format
|
||||||
width, // Output image width
|
width, // Output image width
|
||||||
height, // Output image height
|
height, // Output image height
|
||||||
quality, // Output image quality
|
quality, // Output image quality
|
||||||
@ -258,7 +258,7 @@ export class SmartPdf {
|
|||||||
|
|
||||||
// Resolve all promises and return the array of buffers
|
// Resolve all promises and return the array of buffers
|
||||||
const imageBuffers = await Promise.all(imagePromises);
|
const imageBuffers = await Promise.all(imagePromises);
|
||||||
const imageUint8Arrays = imageBuffers.map((buffer) => new Uint8Array(buffer));
|
const imageUint8Arrays = imageBuffers.map((buffer) => buffer);
|
||||||
return imageUint8Arrays;
|
return imageUint8Arrays;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user