fix(core): update
This commit is contained in:
parent
addff418c6
commit
3df4e103f9
@ -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.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,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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user