« Linux tools PDF » : différence entre les versions
| (4 versions intermédiaires par le même utilisateur non affichées) | |||
| Ligne 56 : | Ligne 56 : | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== ℹ️ À noter == | ==== ℹ️ À noter ==== | ||
Le paquet '''<code>poppler-utils</code>''' fournit plusieurs outils PDF utiles, dont : | Le paquet '''<code>poppler-utils</code>''' fournit plusieurs outils PDF utiles, dont : | ||
| Ligne 129 : | Ligne 129 : | ||
✅ Extraction rapide du texte ✅ Outil léger et scriptable ✅ Parfait pour OCR / indexation ✅ Intégration facile dans des pipelines shell | ✅ Extraction rapide du texte ✅ Outil léger et scriptable ✅ Parfait pour OCR / indexation ✅ Intégration facile dans des pipelines shell | ||
----- | |||
== '''🧰 <code>pdfinfo</code> ''' == | |||
(fournie par `poppler-utils`) | |||
=== 1️⃣ Informations de base sur un PDF === | |||
<syntaxhighlight lang="bash">pdfinfo document.pdf</syntaxhighlight> | |||
Exemple de sortie : | |||
<pre>Title: Rapport annuel | |||
Author: ACME Corp | |||
Creator: LibreOffice | |||
Producer: LibreOffice | |||
CreationDate: Mon Jan 15 10:22:00 2024 | |||
ModDate: Tue Jan 16 09:10:00 2024 | |||
Pages: 42 | |||
Page size: 595 x 842 pts (A4) | |||
File size: 1234567 bytes | |||
PDF version: 1.7</pre> | |||
----- | |||
=== 2️⃣ Obtenir uniquement le nombre de pages === | |||
<syntaxhighlight lang="bash">pdfinfo document.pdf | grep Pages</syntaxhighlight> | |||
Utile pour : | |||
* scripts | |||
* validation avant traitement | |||
* automatisation (batch PDF) | |||
----- | |||
=== 3️⃣ Connaître la taille et l’orientation des pages === | |||
<syntaxhighlight lang="bash">pdfinfo document.pdf | grep "Page size"</syntaxhighlight> | |||
Résultat typique : | |||
<pre>Page size: 842 x 595 pts (A4)</pre> | |||
➡️ paysage (landscape) | |||
----- | |||
=== 4️⃣ Vérifier si le PDF est protégé === | |||
<syntaxhighlight lang="bash">pdfinfo document.pdf | grep Encrypted</syntaxhighlight> | |||
Sortie possible : | |||
<pre>Encrypted: yes</pre> | |||
👉 Indique qu’un mot de passe est requis (à traiter ensuite avec <code>qpdf</code>) | |||
----- | |||
=== 5️⃣ Afficher les métadonnées complètes === | |||
<syntaxhighlight lang="bash">pdfinfo -meta document.pdf</syntaxhighlight> | |||
Affiche les métadonnées XMP (XML), très utile pour : | |||
* audit | |||
* conformité | |||
* analyse forensique légère | |||
----- | |||
=== 6️⃣ Informations page par page === | |||
<syntaxhighlight lang="bash">pdfinfo -box document.pdf</syntaxhighlight> | |||
Montre : | |||
* MediaBox | |||
* CropBox | |||
* BleedBox | |||
* TrimBox | |||
Utile en '''impression professionnelle'''. | |||
----- | |||
=== 7️⃣ Script shell : compter les pages === | |||
<syntaxhighlight lang="bash">PAGES=$(pdfinfo document.pdf | awk '/Pages/ {print $2}') | |||
echo "Nombre de pages : $PAGES"</syntaxhighlight> | |||
----- | |||
=== 8️⃣ Tester si un PDF contient du texte exploitable === | |||
<syntaxhighlight lang="bash">pdfinfo document.pdf && pdftotext document.pdf -</syntaxhighlight> | |||
➡️ si <code>pdftotext</code> ne sort rien → PDF scanné | |||
----- | |||
=== 9️⃣ Batch sur plusieurs fichiers === | |||
<syntaxhighlight lang="bash">for f in *.pdf; do | |||
echo "== $f ==" | |||
pdfinfo "$f" | grep Pages | |||
done</syntaxhighlight> | |||
----- | |||
=== ⚠️ Notes importantes === | |||
* <code>pdfinfo</code> '''n’extrait pas le texte''' | |||
* il '''n’altère jamais''' le fichier | |||
* fonctionne même sur PDF protégés (lecture des infos seulement) | |||
----- | |||
=== 🧠 Résumé rapide === | |||
{| class="wikitable" | |||
|- | |||
! Besoin | |||
! Commande | |||
|- | |||
| Infos générales | |||
| <code>pdfinfo file.pdf</code> | |||
|- | |||
| Pages | |||
| <code>grep Pages</code> | |||
|- | |||
| Sécurité | |||
| <code>grep Encrypted</code> | |||
|- | |||
| Métadonnées | |||
| <code>pdfinfo -meta</code> | |||
|- | |||
| Mise en page | |||
| <code>pdfinfo -box</code> | |||
|} | |||
----- | ----- | ||
| Ligne 212 : | Ligne 352 : | ||
----- | ----- | ||
== '''🧰 <code>ExifTool</code> ''' == | |||
voir [[Logiciels_terminal#🧰_ExifTool|ExifTool]] | |||
[[Catégorie:Linux]] [[Catégorie:Tools]] [[Catégorie: Terminal Tools]] | [[Catégorie:Linux]] [[Catégorie:Tools]] [[Catégorie: Terminal Tools]] | ||