fix(core): update

This commit is contained in:
Philipp Kunz 2024-04-27 12:07:16 +02:00
parent addff418c6
commit 3df4e103f9
3 changed files with 6 additions and 6 deletions

View File

@ -55,8 +55,8 @@ tap.test('should merge pdfs', async () => {
tap.test('should create images from an pdf', async () => {
const pdfObject = await testSmartPdf.readFileToPdfObject('.nogit/combined.pdf');
const images = await testSmartPdf.convertPDFToJPGBytes(pdfObject.buffer);
console.log(images);
const images = await testSmartPdf.convertPDFToPngBytes(pdfObject.buffer);
console.log(images.map((val) => val.length));
});
tap.test('should be able to close properly', async () => {

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
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.'
}

View File

@ -225,7 +225,7 @@ export class SmartPdf {
return deferred.promise;
}
public async convertPDFToJPGBytes(
public async convertPDFToPngBytes(
pdfBytes: Uint8Array,
options: {
width?: number;
@ -240,7 +240,7 @@ export class SmartPdf {
const converter = plugins.pdf2pic.fromBuffer(Buffer.from(pdfBytes), {
density: 100, // Image density (DPI)
format: 'jpg', // Image format
format: 'png', // Image format
width, // Output image width
height, // Output image height
quality, // Output image quality
@ -258,7 +258,7 @@ export class SmartPdf {
// Resolve all promises and return the array of buffers
const imageBuffers = await Promise.all(imagePromises);
const imageUint8Arrays = imageBuffers.map((buffer) => new Uint8Array(buffer));
const imageUint8Arrays = imageBuffers.map((buffer) => buffer);
return imageUint8Arrays;
}
}