PDFTOPIC By Ilyes-El-Majouti
Documentation en français
Installation de ImageMagick CLI
Sur macOS
- Assurez-vous que Homebrew est installé sur votre système.
- Ouvrez le terminal et tapez la commande suivante:
brew install imagemagick
Sur Linux
Debian et Ubuntu
- Ouvrez le terminal et tapez la commande suivante:
sudo apt-get update
- Tapez la commande suivante pour installer ImageMagick:
sudo apt-get install imagemagick
Fedora
- Ouvrez le terminal et tapez la commande suivante:
sudo dnf install imagemagick
CentOS
- Ouvrez le terminal et tapez la commande suivante:
sudo yum install imagemagick
On Windows
- Téléchargez l'installeur ImageMagick pour Windows à partir de la page de téléchargement officielle.
- 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.
- 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.
- 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.
- Dans la boîte de dialogue "Installer", cliquez sur le bouton "Installer" pour commencer l'installation.
- 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
ouconvert
. Si vous voyez une liste d'options de commande, c'est que ImageMagick CLI est installé correctement.
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
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
const { pdftobuffer } = require('pdftopic');
const fs = require('fs');
const pdf = fs.readFileSync('./ilyes.pdf', null);
pdftobuffer(pdf, 0).then((buffer) => {
fs.writeFileSync('./ilyes.png', buffer, null);
})
Résultat après avoir exécuté le code
Ensuite tu trouveras ton fichier converti avec ton extension pour ma part PNG
Avant
Après
https://github.com/Ilyes-El-Majouti/pdftopic)
Vous retrouverez les fichiers sur le github (💪 😉
Liker si vous avez aimé le code ça me ferait très plaisir Documentation in English
Installing ImageMagick CLI
On macOS
- Make sure you have Homebrew installed on your system.
- Open the terminal and type the following command:
brew install imagemagick
On Linux
Debian and Ubuntu
- Open the terminal and type the following command:
sudo apt-get update
- Type the following command to install ImageMagick:
sudo apt-get install imagemagick
Fedora
- Open the terminal and type the following command:
sudo dnf install imagemagick
CentOS
- Open the terminal and type the following command:
sudo yum install imagemagick
On Windows
- Download the ImageMagick installer for Windows from the official download page.
- 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.
- In the "Choose components to install" dialog box, select at least "Install command-line utilities" to install the CLI version of ImageMagick.
- 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.
- In the "Install" dialog box, click the "Install" button to start the installation.
- 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
orconvert
. If you see a list of command options, then ImageMagick CLI is installed correctly.
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
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
npm install pdftopic
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.
const { pdftobuffer } = require('pdftopic');
const fs = require('fs');
const pdf = fs.readFileSync('./ilyes.pdf', null);
pdftobuffer(pdf, 0).then((buffer) => {
fs.writeFileSync('./ilyes.png', buffer, null);
})
Result after running the code
Then you will find your converted file with your extension for my part PNG
Before
After
https://github.com/Ilyes-El-Majouti/pdftopic)
You will find the files on the github (💪 😉
Like if you liked the code it would make me very happy Documentación en español
Instalación de ImageMagick CLI
En macOS
- Asegúrese de tener Homebrew instalado en su sistema.
- Abra la terminal y escriba el siguiente comando:
brew install imagemagick
En Linux
Debian y Ubuntu
- Abra la terminal y escriba el siguiente comando:
sudo apt-get update
- Escriba el siguiente comando para instalar ImageMagick:
sudo apt-get install imagemagick
Fedora
- Abra la terminal y escriba el siguiente comando:
sudo dnf install imagemagick
CentOS
- Abra la terminal y escriba el siguiente comando:
sudo yum install imagemagick
En Windows
- Descargue el instalador de ImageMagick para Windows desde la página de descarga oficial.
- 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.
- 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.
- 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.
- En el cuadro de diálogo "Instalar", haga clic en el botón "Instalar" para comenzar la instalación.
- 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
oconvert
. Si ve una lista de opciones de comando, entonces ImageMagick CLI se ha instalado correctamente.
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
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
npm install pdftopic
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.
const { pdftobuffer } = require('pdftopic');
const fs = require('fs');
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
Luego encontrará su archivo convertido con su extensión para mí PNG
Antes
Después