New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

pdftopic

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pdftopic - npm Package Compare versions

Comparing version 0.2.0 to 1.0.0-alpha

.github/workflows/npm-publish.yml

119

index.js

@@ -5,9 +5,31 @@ const imagemagick = require("imagemagick-stream");

const streamtoarray = require('stream-to-array');
const { PDFDocument } = require('pdf-lib');
const sharp = require('sharp');
const ProgressBar = require('progress');
function pdftostream(pdf, page) {
const pdftobuffer = async (pdf, page, progress = false) => {
const pdfcount = await pdftocount(pdf);
assert(Buffer.isBuffer(pdf) || isstream.readable(pdf), 'The pdf must be either a readable stream or a buffer');
assert(typeof page === 'number', `page should be one number, given ${page}`);
assert(page % 1 === 0, `page should be an integer, given ${page}`);
assert(page >= 0, `the page must be equal to or greater than 0 in the case of ${page}`);
if (page !== "all" && !Array.isArray(page)) {
assert((pdfcount - 1) >= page, 'the page does not exist please try again');
assert(typeof page === 'number', `page should be one number, given ${page}`);
assert(Number.isInteger(page), `page should be an integer, given ${page}`);
assert(page >= 0, `the page must be equal to or greater than 0 in the case of ${page}`);
} else if(Array.isArray(page)) {
Array.from(page, (_) => assert((pdfcount - 1) >= _, 'the page does not exist please try again'));
}
const bar = progress ? new ProgressBar('Processing [:bar] :percent :etas', { complete: '=', incomplete: ' ', width: 30, total: page === "all" ? pdfcount : 1 }) : null;
if (page === "all" || Array.isArray(page)) {
const promises = Array.from(Array.isArray(page) ? page : { length: pdfcount }, (_, index) => imagemagickconverter(pdf, Array.isArray(page) ? _ : index, progress ? bar : null));
return Promise.all(promises);
} else {
return [await imagemagickconverter(pdf, page, progress ? bar : null)];
}
}
const imagemagickconverter = async (pdf, page, bar) => {
const imagemagickstream = imagemagick()

@@ -19,3 +41,3 @@ .set('density', 200)

.set("flatten");
const onError = imagemagickstream.onerror;

@@ -32,6 +54,3 @@

if (typeof page !== 'undefined') {
imagemagickstream.input = `pdf:-[${page}]`;
}
imagemagickstream.input = `pdf:-[${page}]`;
imagemagickstream.output = 'png:-';

@@ -45,20 +64,82 @@

return imagemagickstream;
const parts = await streamtoarray(imagemagickstream);
const buffers = parts.map(part => Buffer.isBuffer(part) ? part : Buffer.from(part));
const resultBuffer = Buffer.concat(buffers);
if (bar) {
bar.tick();
}
return resultBuffer;
}
function pdftobuffer(pdf, page) {
return streamtoarray(pdftostream(pdf, page)).then((parts) => {
const buffers = parts.map((part) => {
return Buffer.isBuffer(part) ? part : Buffer.from(part);
});
return Buffer.concat(buffers);
const pdftocount = async (pdf) => {
const pdfDoc = await PDFDocument.load(pdf);
return pdfDoc.getPageCount();
};
const bufferstoappend = async (buffers) => {
const dimmention = await getDimmentions(buffers);
const outputImgWidth = dimmention.outputImgWidth;
const outputImgHeight = dimmention.outputImgHeight;
const compositeParams = await Promise.allSettled(buffers.map(async (buffer, index) => {
const image = await sharp(buffer);
const metadata = await image.metadata();
const top = dimmention.dimmentions.slice(0, index).reduce((acc, item) => acc + item.height, 0);
return {
input: await image.resize(metadata.width).toBuffer(),
gravity: "northwest",
left: 0,
top: top
};
}));
const params = compositeParams.filter(result => result.status === 'fulfilled').map(result => result.value);
return await sharp({
create: {
width: outputImgWidth,
height: outputImgHeight,
channels: dimmention.channels,
background: { r: 255, g: 255, b: 255, alpha: 0 }
}
})
.composite(params)
.png()
.toBuffer();
}
const getDimmentions = async (buffers) => {
const promises = buffers.map(async (buffer) => {
const bufferImage = await sharp(buffer);
const metadata = await bufferImage.metadata();
return {
width: metadata.width,
height: metadata.height
}
});
const dimmentions = await Promise.all(promises);
const max_width = Math.max(...dimmentions.map(item => item.width));
const total_height = dimmentions.map(item => item.height).reduce((acc, item) => acc + item, 0);
return {
outputImgWidth: max_width,
outputImgHeight: total_height,
dimmentions,
channels: dimmentions.length
}
}
module.exports = { pdftostream, pdftobuffer }
module.exports = { pdftocount, pdftobuffer, bufferstoappend, getDimmentions };
/*******************************************/
/************** PDF TO IMAGE ***************/
/***************** PDFTOPIC ****************/
/******* CREATE BY Ilyes-El-Majouti ********/
/*** https://github.com/Ilyes-El-Majouti ***/
/*******************************************/

@@ -1,9 +0,51 @@

const { pdftobuffer } = require("./");
const exp = require("constants");
const pdftopic = require("./");
const fs = require("fs");
test('converting pdf to png', () => {
const pdf = fs.readFileSync('./ilyes.pdf', null);
return expect(pdftobuffer(pdf, 0).then((buffer) => {
fs.writeFileSync('./test.png', buffer, null);
})).resolves.not.toBeNull();
/*test('converting pdftopic@0.1.3 (single file)', async () => {
const pdf = fs.readFileSync('./pdf_files/ilyes.pdf');
const result = await pdftobuffer(pdf, 0);
expect(result).not.toBeNull();
});
test('converting pdftopic@0.1.3 (multiple file)', async () => {
const pdf = fs.readFileSync('./pdf_files/curriculum_vitae.pdf');
var results = [];
for (let index = 0; index < 4; index++) {
const result = await pdftobuffer(pdf, index);
results.push(result);
}
expect(results).not.toBeNull();
});*/
/*test('converting pdftopic@1.0.0 (single file)', async () => {
const pdf = fs.readFileSync('./pdf_files/ilyes.pdf');
const result = await pdftopic.pdftobuffer(pdf, 0);
expect(result).not.toBeNull();
});
test('converting pdftopic@1.0.0 (specific files)', async () => {
const pdf = fs.readFileSync('./pdf_files/curriculum_vitae.pdf');
const result = await pdftopic.pdftobuffer(pdf, [ 1, 3 ]);
expect(result).not.toBeNull();
});
test('converting pdftopic@1.0.0 (multiple file)', async () => {
const pdf = fs.readFileSync('./pdf_files/curriculum_vitae.pdf');
const result = await pdftopic.pdftobuffer(pdf, "all");
expect(result).not.toBeNull();
});*/
test('converting pdftopic@1.0.0 (all images in one image)', async () => {
const file1 = fs.readFileSync('./curriculum_vitae-converted/curriculum_vitae-0.png');
const file2 = fs.readFileSync('./curriculum_vitae-converted/curriculum_vitae-1.png');
const file3 = fs.readFileSync('./curriculum_vitae-converted/curriculum_vitae-2.png');
const file4 = fs.readFileSync('./curriculum_vitae-converted/curriculum_vitae-3.png');
const allfiles = [ file1, file2, file3, file4 ];
const result = await pdftopic.bufferstoappend(allfiles);
expect(result).not.toBeNull();
fs.writeFileSync('./curriculum_vitae.png', result);
});

111

package.json
{
"name": "pdftopic",
"version": "0.2.0",
"description": "NODEJS This package allows you to convert a PDF to any image format (png, jpg, gif, ...) in very good quality",
"main": "index.js",
"scripts": {
"test": "jest"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Ilyes-El-Majouti/pdftopic.git"
},
"keywords": [
"pdf to image",
"pdf to jpg",
"pdf to png",
"pdf2png",
"pdftopng",
"pdftoimage",
"pdftoimages",
"pdf-to-image",
"pdf-to-images",
"pdf-to-png",
"pdf-to-png",
"pdf",
"image",
"jpg",
"jpeg",
"png",
"pdf-images",
"pdf2images"
],
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/Ilyes-El-Majouti/pdftopic/issues"
},
"homepage": "https://github.com/Ilyes-El-Majouti/pdftopic#readme",
"dependencies": {
"fs": "^0.0.1-security",
"imagemagick-stream": "^4.1.1",
"is-stream": "^1.1.0",
"stream-to-array": "^2.3.0"
}
"name": "pdftopic",
"version": "1.0.0-alpha",
"description": "Built for Node.js, this package empowers users to effortlessly convert PDF files into images of exceptional quality, supporting multiple formats including PNG, JPG, GIF, and others. Its streamlined functionality ensures a smooth and reliable conversion process, providing users with the flexibility to obtain top-notch images from their PDF documents",
"main": "index.js",
"scripts": {
"test": "jest"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Ilyes-El-Majouti/pdftopic.git"
},
"keywords": [
"pdf to image",
"pdf to jpg",
"pdf to png",
"pdf2png",
"pdftopng",
"pdf2pic",
"pdftoimage",
"pdftoimages",
"pdf-to-image",
"pdf-to-images",
"pdf-to-png",
"pdf-to-png",
"pdf",
"image",
"jpg",
"jpeg",
"png",
"pdf-images",
"pdf2images",
"PDF",
"PDF to image conversion",
"visual content extraction",
"image processing",
"Node.js",
"PNG",
"JPG",
"image quality",
"content extraction",
"PDF tools",
"Node.js library",
"conversion tool",
"content extraction tool",
"PDF visualization",
"open-source",
"graphics",
"file conversion"
],
"author": "Ilyes-El-Majouti",
"license": "ISC",
"bugs": {
"url": "https://github.com/Ilyes-El-Majouti/pdftopic/issues"
},
"homepage": "https://github.com/Ilyes-El-Majouti/pdftopic#readme",
"dependencies": {
"assert": "^2.1.0",
"imagemagick-stream": "^4.1.1",
"is-stream": "^1.1.0",
"pdf-lib": "^1.17.1",
"progress": "^2.0.3",
"sharp": "^0.32.6",
"stream": "^0.0.2",
"stream-to-array": "^2.3.0"
},
"devDependencies": {
"jest": "^29.7.0"
}
}

@@ -1,215 +0,202 @@

<img src="https://repository-images.githubusercontent.com/518815977/51d3dd60-7078-4652-b458-ce043754c7bd">
<img src="https://repository-images.githubusercontent.com/518815977/e762deba-30c4-45ff-8792-ad6769a7f26e">
## **PDFTOPIC *By Ilyes-El-Majouti***
<center>
[<img src="https://img.shields.io/badge/PDFTOPIC-010101?&style=for-the-badge&logo=Npm&logoColor=white"/>](https://www.npmjs.com/package/pdftopic)
![Version-Project](https://img.shields.io/github/package-json/v/Ilyes-El-Majouti/pdftopic?style=flat-square&logo=npm)
[![Donate](https://img.shields.io/badge/donate-PayPal-green?style=flat-square&color=blue)](https://www.paypal.me/IlyesElMajouti)
![Minified-Size](https://img.shields.io/bundlephobia/min/pdftopic?style=flat-square)
![Download-Month](https://img.shields.io/npm/dm/pdftopic?style=flat-square)
![License-Project](https://img.shields.io/github/license/Ilyes-El-Majouti/pdftopic?style=flat-square)
[![Stars-Project](https://img.shields.io/github/stars/Ilyes-El-Majouti/pdftopic?style=flat-square&color=red)](https://github.com/Ilyes-El-Majouti/pdftopic)
![Last-Commit](https://img.shields.io/github/last-commit/Ilyes-El-Majouti/pdftopic?style=flat-square)
### **Documentation en français**
</center>
The `pdftopic` package offers an advanced solution for converting PDF files into various image formats such as PNG, JPG, etc. With a particular focus on rendering quality, `pdftopic` distinguishes itself by producing output of exceptional quality, surpassing the performance of other packages available on the market. Designed to meet the critical needs of demanding users, `pdftopic` effectively and reliably solves the rendering quality problems that many other packages present, offering an unrivalled and reliable PDF conversion solution for developers and IT professionals.
### **Installation de ImageMagick CLI**
> IMPORTANT NOTE: We strongly encourage you to support this library by making a donation via [PayPal](https://www.paypal.me/IlyesElMajouti). Your generosity is highly appreciated, and we also welcome contributors with gratitude!
### **Sur macOS**
### **Prerequisites**
1. Assurez-vous que [Homebrew](https://brew.sh/) est installé sur votre système.
2. Ouvrez le terminal et tapez la commande suivante: `brew install imagemagick`
* node >= 12.x
* imagemagick
### **Sur Linux**
**Debian et Ubuntu**
1. Ouvrez le terminal et tapez la commande suivante: `sudo apt-get update`
2. Tapez la commande suivante pour installer ImageMagick: `sudo apt-get install imagemagick`
### Don't have imagemagick yet ?
**Fedora**
1. Ouvrez le terminal et tapez la commande suivante: `sudo dnf install imagemagick`
Follow [this](docs/dependencies-installation.md) guide to install the required dependencies.
**CentOS**
1. Ouvrez le terminal et tapez la commande suivante: `sudo yum install imagemagick`
## Installation
### **On Windows**
```bash
npm install --save pdftopic
```
1. Téléchargez l'installeur ImageMagick pour Windows à partir de [la page de téléchargement officielle](https://imagemagick.org/script/download.php#windows).
2. Exécutez l'installeur que vous venez de télécharger. Vous pouvez choisir de cocher ou décocher les options d'installation en fonction de vos besoins. Si vous n'êtes pas sûr de quoi choisir, vous pouvez laisser les options par défaut.
3. Dans la boîte de dialogue "Choisir les composants à installer", sélectionnez au moins "Install command-line utilities" pour installer la version CLI d'ImageMagick.
4. Dans la boîte de dialogue "Sélectionner les dossiers d'installation", choisissez l'emplacement où vous voulez installer ImageMagick sur votre ordinateur. Vous pouvez laisser l'emplacement par défaut si vous n'avez pas de préférence particulière.
5. Dans la boîte de dialogue "Installer", cliquez sur le bouton "Installer" pour commencer l'installation.
6. Une fois l'installation terminée, vous pouvez vérifier que ImageMagick CLI est installé en ouvrant un invite de commande (cmd.exe) et en tapant la commande `magick` ou `convert`. Si vous voyez une liste d'options de commande, c'est que ImageMagick CLI est installé correctement.
## Usage
---
### Converting specific page of PDF from buffer, then saving as image file
Ce package permet de convertir un PDF en n'importe quels formats d'image (png, jpg, gif, ...) en très bonne qualité. le package avec la meilleure qualité de rendu, après avoir essayé plusieurs packages les qualités de rendu était horrible du coup j'ai décidé de créer ce package qui ressoudera ce souci a plus d'une personne 😉.
Si vous voulez une version pour convertir avec express js envoyez moi un message sur github ou faite un issues pour me le faire savoir
### **Comment l'utiliser ?**
Avant tout il faut installer le package sur npm ou github avec la commande suivante
```sh
npm install pdftopic
```
Ensuite après avoir installé le package il vous suffira d'importer dans votre code Javascript la partie suivante pour cet exemple je souhaite convertir un fichier PDF en format PNG
```javascript
const { pdftobuffer } = require('pdftopic');
const fs = require('fs');
import pdftopic from "pdftopic";
import fs from "fs";
const pdf = fs.readFileSync('./ilyes.pdf', null);
(async () => {
const curriculum_vitae = fs.readFileSync('./pdf_files/curriculum_vitae.pdf');
pdftobuffer(pdf, 0).then((buffer) => {
fs.writeFileSync('./ilyes.png', buffer, null);
})
const converted_result = await pdftopic.pdftobuffer(pdf, 0);
fs.writeFileSync(`./png_files/curriculum_vitae.png`, converted_result[0]);
})();
```
### **Résultat après avoir exécuté le code**
Ensuite tu trouveras ton fichier converti avec ton extension pour ma part PNG
### Converting specific pages of PDF from buffer, then saving as image file
**Avant**
```javascript
import pdftopic from "pdftopic";
import fs from "fs";
![preview in file pdf](./ilyes-pdf.png)
(async () => {
const curriculum_vitae = fs.readFileSync('./pdf_files/curriculum_vitae.pdf');
**Après**
const converted_result = await pdftopic.pdftobuffer(pdf, [ 1, 3 ]);
converted_result.forEach((file, index) => {
fs.writeFileSync(`./curriculum_vitae-${index}.png`, file);
});
})();
```
![preview convert file](./ilyes.png)
### Converting all pages of PDF from buffer, then saving as image file
#### **Vous retrouverez les fichiers sur le github (https://github.com/Ilyes-El-Majouti/pdftopic)**
<br>
```javascript
import pdftopic from "pdftopic";
import fs from "fs";
### **Liker si vous avez aimé le code ça me ferait très plaisir 💪😉**
(async () => {
const curriculum_vitae = fs.readFileSync('./pdf_files/curriculum_vitae.pdf');
---
<br>
const converted_result = await pdftopic.pdftobuffer(pdf, "all");
converted_result.forEach((file, index) => {
fs.writeFileSync(`./png_files/curriculum_vitae-${index}.png`, file);
});
})();
```
### **Documentation in English**
### Converting all pages of PDF from buffer, then concat images and save image file
### **Installing ImageMagick CLI**
```javascript
import pdftopic from "pdftopic";
import fs from "fs";
### **On macOS**
(async () => {
const curriculum_vitae = fs.readFileSync('./pdf_files/curriculum_vitae.pdf');
1. Make sure you have [Homebrew](https://brew.sh/) installed on your system.
2. Open the terminal and type the following command: `brew install imagemagick`
const converted_result = await pdftopic.pdftobuffer(pdf, "all");
const concat_converted_result = await pdftopic.bufferstoappend(allfiles);
### **On Linux**
**Debian and Ubuntu**
1. Open the terminal and type the following command: `sudo apt-get update`
2. Type the following command to install ImageMagick: `sudo apt-get install imagemagick`
fs.writeFileSync(`./png_files/curriculum_vitae-big.png`, concat_converted_result);
})();
```
**Fedora**
1. Open the terminal and type the following command: `sudo dnf install imagemagick`
## PDFTOPIC API
**CentOS**
1. Open the terminal and type the following command: `sudo yum install imagemagick`
- [pdftobuffer(buffer, page, progress)](#pdftobufferbuffer-page-progress)
- [bufferstoappend(buffers, progress)](#bufferstoappendbuffers-progress)
- [pdftocount(buffer)](#pdftocountbuffer)
- [getDimmentions(buffers)](#getdimmentionsbuffers)
### **On Windows**
### pdftobuffer(buffer, page, progress)
1. Download the ImageMagick installer for Windows from the [official download page](https://imagemagick.org/script/download.php#windows).
2. Run the installer that you just downloaded. You can choose to check or uncheck installation options depending on your needs. If you're not sure what to choose, you can leave the options as default.
3. In the "Choose components to install" dialog box, select at least "Install command-line utilities" to install the CLI version of ImageMagick.
4. In the "Select installation folder" dialog box, choose the location where you want to install ImageMagick on your computer. You can leave the location as default if you don't have any particular preference.
5. In the "Install" dialog box, click the "Install" button to start the installation.
6. Once the installation is complete, you can verify that ImageMagick CLI is installed by opening a command prompt (cmd.exe) and typing the command `magick` or `convert`. If you see a list of command options, then ImageMagick CLI is installed correctly.
Initiate the conversion of a PDF to a buffer by supplying the function with a PDF and a specific page number or 'all' for the entire document. The function validates the input and processes the conversion accordingly, with an optional progress bar to track the process.
---
#### Functions
This package allows you to convert a PDF to any image formats (png, jpg, gif, ...) in very good quality. the package with the best rendering quality, after trying several packages the rendering qualities were horrible so I decided to create this package which will solve this problem for more than one person 😉.
Convert a specific page of the PDF to Image/Buffer by supplying a file path.
If you want a version to convert with express js send me a message on github or do an issues to let me know
### **How to use it ?**
First of all you have to install the package on npm or github with the following command
```sh
npm install pdftopic
```javascript
pdftobuffer(buffer, page, progress)
```
Then after installing the package, you just need to import the following part into your Javascript code. For this example, I want to convert a PDF file to PNG format.
```javascript
const { pdftobuffer } = require('pdftopic');
const fs = require('fs');
* buffer - buffer pdf file
* page - page number to convert to an image
* progress - progress converting.
const pdf = fs.readFileSync('./ilyes.pdf', null);
---
pdftobuffer(pdf, 0).then((buffer) => {
fs.writeFileSync('./ilyes.png', buffer, null);
})
Converts PDF to Image/Buffer by supplying a file path
```javascript
pdftobuffer(buffer, pages, progress)
```
### **Result after running the code**
* buffer - buffer pdf file
* pages - page numbers to convert to image
* set `pages` to `"all"` to convert all pages
* `pages` also accepts an array indicating the page number e.g. `[1,2,3]`
* also accepts number e.g. `1`
* progress - progress converting
* set `false` to disable progressbar (in default)
* set `true` to enable progressbar
Then you will find your converted file with your extension for my part PNG
---
### bufferstoappend(buffers, progress)
**Before**
Kick-start the concatenation of multiple buffers by feeding the function with an array of buffers.
![preview in file pdf](./ilyes-pdf.png)
#### Functions
**After**
Concatenate multiple buffers into a single buffer by providing an array of buffers to the function. The function processes each buffer, appends them together, and returns the combined buffer.
![preview convert file](./ilyes.png)
#### **You will find the files on the github (https://github.com/Ilyes-El-Majouti/pdftopic)**
<br>
### **Like if you liked the code it would make me very happy 💪😉**
```javascript
bufferstoappend(buffers, progress)
```
* buffers - array of buffers images
---
<br>
### **Documentación en español**
### pdftocount(buffer)
### **Instalación de ImageMagick CLI**
Start the process of counting the number of pages in a PDF by providing a PDF buffer to the function.
### **En macOS**
#### Functions
1. Asegúrese de tener [Homebrew](https://brew.sh/) instalado en su sistema.
2. Abra la terminal y escriba el siguiente comando: `brew install imagemagick`
Determine the total number of pages in a PDF document by supplying the PDF to the function. The function loads the PDF and returns the page count.
### **En Linux**
**Debian y Ubuntu**
1. Abra la terminal y escriba el siguiente comando: `sudo apt-get update`
2. Escriba el siguiente comando para instalar ImageMagick: `sudo apt-get install imagemagick`
```javascript
pdftocount(buffer)
```
* buffer - buffer pdf file
**Fedora**
1. Abra la terminal y escriba el siguiente comando: `sudo dnf install imagemagick`
---
**CentOS**
1. Abra la terminal y escriba el siguiente comando: `sudo yum install imagemagick`
### getDimmentions(buffers)
### **En Windows**
To use the `getDimmentions` function, you need to provide an array of buffers as input. Each element of this array must represent an image in buffer form. Make sure that each buffer in the array corresponds to a valid image. Once you've supplied this array of buffers, you can use it as an argument to call the `getDimmentions` function.
1. Descargue el instalador de ImageMagick para Windows desde la [página de descarga oficial](https://imagemagick.org/script/download.php#windows).
2. Ejecute el instalador que acaba de descargar. Puede elegir marcar o desmarcar las opciones de instalación según sus necesidades. Si no está seguro de qué elegir, puede dejar las opciones como predeterminadas.
3. En el cuadro de diálogo "Elegir los componentes a instalar", seleccione al menos "Instalar utilidades de línea de comandos" para instalar la versión CLI de ImageMagick.
4. En el cuadro de diálogo "Seleccionar carpeta de instalación", elija la ubicación donde desea instalar ImageMagick en su computadora. Puede dejar la ubicación como predeterminada si no tiene ninguna preferencia en particular.
5. En el cuadro de diálogo "Instalar", haga clic en el botón "Instalar" para comenzar la instalación.
6. Una vez que se complete la instalación, puede verificar que ImageMagick CLI está instalado abriendo un símbolo del sistema (cmd.exe) y escribiendo el comando `magick` o `convert`. Si ve una lista de opciones de comando, entonces ImageMagick CLI se ha instalado correctamente.
#### Functions
---
The `getDimmentions` function is an asynchronous function that takes an array of buffers as an argument. The function returns an object containing the following information:
Este paquete te permite convertir un PDF a cualquier formato de imagen (png, jpg, gif, ...) en muy buena calidad. el paquete con la mejor calidad de renderizado, después de probar varios paquetes las calidades de renderizado eran horribles, así que decidí crear este paquete que resolverá este problema para más de una persona 😉.
- outputImgWidth: the maximum width of all the images in the array.
- outputImgHeight: the sum total of the heights of all the images in the array.
- dimmentions: an array containing the dimensions (width and height) of each image in {width, height} format.
- channels: the number of elements in the dimensions array, corresponding to the number of images processed.
Si desea una versión para convertir con express js, envíeme un mensaje en github o haga un problema para avisarme
### **Comment l'utiliser ?**
En primer lugar, debe instalar el paquete en npm o github con el siguiente comando
```sh
npm install pdftopic
```javascript
getDimmentions(buffers)
```
Luego, después de instalar el paquete, solo necesita importar la siguiente parte en su código Javascript para este ejemplo. Quiero convertir un archivo PDF a formato PNG.
```javascript
const { pdftobuffer } = require('pdftopic');
const fs = require('fs');
* buffers - array of buffers images
const pdf = fs.readFileSync('./ilyes.pdf', null);
pdftobuffer(pdf, 0).then((buffer) => {
fs.writeFileSync('./ilyes.png', buffer, null);
})
```
### **Resultado después de ejecutar el código**
## New updates
Luego encontrará su archivo convertido con su extensión para mí PNG
### `[UPDATE]` Simple file conversion
**Antes**
![Comparison between old and new versions](./docs/images/single_file.png)
As part of this update, a comparative evaluation of conversion speed was carried out on a single file between version `pdftopic@0.1.3` and the latest version `pdftopic@1.0.0`. This analysis revealed a significant improvement in conversion performance in the latest version, demonstrating a clear acceleration in the conversion process.
![preview in file pdf](./ilyes-pdf.png)
### `[UPDATE]` Multiple file conversion
**Después**
![Comparison between old and new versions](./docs/images/multiple_files.png)
In line with this update, a comparative analysis of conversion speed was carried out between the previous version `pdftopic@0.1.3` and the current version `pdftopic@1.0.0`, based on the processing of several files. This evaluation demonstrated a significant improvement in conversion performance in the more recent version, highlighting a clear acceleration in the conversion process.
![preview convert file](./ilyes.png)
### `[ADDITION]` Concatenate multiple images into a single visual entity
#### **Encontrará los archivos en github (https://github.com/Ilyes-El-Majouti/pdftopic)**
<br>
### **Like si te gusto el código me haría muy feliz 💪😉**
![Concatenate multiple images](./docs/images/concat_files.png)
In line with this update, the current version of `pdftopic@1.0.0` has been enhanced by the integration of an image merge feature, enabling multiple images to be combined into a single visual entity. Although this feature is still in the beta phase, we are currently working on an improved beta version, offering even faster merging speeds than those currently available.
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