Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
46fbb615a0 | |||
3df4e103f9 | |||
addff418c6 | |||
14d653e701 | |||
040bac5256 | |||
bf44901a0a |
@ -119,6 +119,6 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
npmci node install stable
|
npmci node install stable
|
||||||
npmci npm install
|
npmci npm install
|
||||||
pnpm install -g @gitzone/tsdoc
|
pnpm install -g @git.zone/tsdoc
|
||||||
npmci command tsdoc
|
npmci command tsdoc
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
|
10
package.json
10
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@push.rocks/smartpdf",
|
"name": "@push.rocks/smartpdf",
|
||||||
"version": "3.1.2",
|
"version": "3.1.5",
|
||||||
"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",
|
||||||
@ -14,10 +14,10 @@
|
|||||||
"buildDocs": "tsdoc"
|
"buildDocs": "tsdoc"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.66",
|
"@git.zone/tsbuild": "^2.1.66",
|
||||||
"@gitzone/tsdoc": "^1.1.12",
|
"@git.zone/tsdoc": "^1.1.12",
|
||||||
"@gitzone/tsrun": "^1.2.44",
|
"@git.zone/tsrun": "^1.2.44",
|
||||||
"@gitzone/tstest": "^1.0.77",
|
"@git.zone/tstest": "^1.0.77",
|
||||||
"@push.rocks/tapbundle": "^5.0.23",
|
"@push.rocks/tapbundle": "^5.0.23",
|
||||||
"@types/node": "^20.12.7"
|
"@types/node": "^20.12.7"
|
||||||
},
|
},
|
||||||
|
1554
pnpm-lock.yaml
generated
1554
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@ -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.2',
|
version: '3.1.5',
|
||||||
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,14 +225,14 @@ 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;
|
||||||
height?: number;
|
height?: number;
|
||||||
quality?: number;
|
quality?: number;
|
||||||
} = {}
|
} = {}
|
||||||
): Promise<Uint8Array[]> {
|
) {
|
||||||
const { width = 1024, height = 768, quality = 100 } = options;
|
const { width = 1024, height = 768, quality = 100 } = options;
|
||||||
|
|
||||||
// Load the PDF document
|
// Load the PDF document
|
||||||
@ -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
|
||||||
@ -257,6 +257,8 @@ export class SmartPdf {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Resolve all promises and return the array of buffers
|
// Resolve all promises and return the array of buffers
|
||||||
return Promise.all(imagePromises);
|
const imageBuffers = await Promise.all(imagePromises);
|
||||||
|
const imageUint8Arrays = imageBuffers.map((buffer) => buffer);
|
||||||
|
return imageUint8Arrays;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user