{"id":506,"date":"2025-09-20T09:14:06","date_gmt":"2025-09-20T09:14:06","guid":{"rendered":"https:\/\/habett.fr\/blog\/?p=506"},"modified":"2025-09-20T09:14:06","modified_gmt":"2025-09-20T09:14:06","slug":"unitethepages","status":"publish","type":"post","link":"https:\/\/habett.fr\/blog\/2025\/09\/unitethepages\/","title":{"rendered":"UniteThePages"},"content":{"rendered":"\n<p>Besoin de r\u00e9unir des PDFs en un seul, pas vraiment compliqu\u00e9 avec pdfunite. Excellent. Dans mon cas, besoin un peu plus sophistiqu\u00e9 car besoin d&rsquo;introduire des signets afin d&rsquo;avoir un document plus agr\u00e9able \u00e0 consulter, d&rsquo;o\u00f9 ce script.<\/p>\n\n\n\n<p>Script en perl mais d\u00e9pendances pour manipuler les fichiers PDF, \u00e0 savoir pdfinfo, pdfunite (brew install Doppler sur Mac et apt install poppler-utils sur linux) et enfin ghostscript. Pas besoin de modules perl sp\u00e9cifiques.<\/p>\n\n\n\n<p><code>#\/usr\/bin\/perl<br>open(STRU,'>','merger.txt');<br>$cursor = 1;<br>foreach $af (@ARGV) {<br>  if(-e $af) {<br>    $ninfo = pdfinfo \"$af\";<br>    my %inf;<br>    foreach $lee (split(\/\\n\/g,$ninfo)) {<br>      if($lee =~ \/^(.<em>?)\\:[\\s\\t]+(\\w.<\/em>)\/) {<br>        $inf{$1} = $2;<br>      }<br>    }<br>    $tito = $inf{'Title'};<br>    $tito = $af unless($tito);<br>    if($inf{'Pages'} =~ \/\\d+\/) {<br>      print STRU \"[\/Page $cursor \/Title ($tito) \/OUT pdfmark\\n\";<br>      $cursor += $inf{'Pages'};<br>    }<br>  }<br>}<br>close(STRU);<br>$units = join(' ',map { \"\\\"$_\\\"\" } @ARGV);<br>pdfunite $units merger.pdf;<br>print gs -sDEVICE=pdfwrite -q -dBATCH -dNOPAUSE -sOutputFile=Merged.pdf -dPDFSETTINGS=\/prepress merger.txt -f merger.pdf;<\/code><br><code>unlink('merger.txt');<br>unlink('merger.pdf');<\/code><\/p>\n\n\n\n<p>Simple et efficace. Peace.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Besoin de r\u00e9unir des PDFs en un seul, pas vraiment compliqu\u00e9 avec pdfunite. Excellent. Dans mon cas, besoin un peu plus sophistiqu\u00e9 car besoin d&rsquo;introduire des signets afin d&rsquo;avoir un document plus agr\u00e9able \u00e0 consulter, d&rsquo;o\u00f9 ce script. Script en perl mais d\u00e9pendances pour manipuler les fichiers PDF, \u00e0 savoir pdfinfo, pdfunite (brew install Doppler &hellip; <a href=\"https:\/\/habett.fr\/blog\/2025\/09\/unitethepages\/\" class=\"more-link\">Continuer la lecture de <span class=\"screen-reader-text\">UniteThePages<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,3],"tags":[91,66,90],"class_list":["post-506","post","type-post","status-publish","format-standard","hentry","category-non-classe","category-pdf","tag-hack","tag-script","tag-tools"],"_links":{"self":[{"href":"https:\/\/habett.fr\/blog\/wp-json\/wp\/v2\/posts\/506","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/habett.fr\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/habett.fr\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/habett.fr\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/habett.fr\/blog\/wp-json\/wp\/v2\/comments?post=506"}],"version-history":[{"count":4,"href":"https:\/\/habett.fr\/blog\/wp-json\/wp\/v2\/posts\/506\/revisions"}],"predecessor-version":[{"id":510,"href":"https:\/\/habett.fr\/blog\/wp-json\/wp\/v2\/posts\/506\/revisions\/510"}],"wp:attachment":[{"href":"https:\/\/habett.fr\/blog\/wp-json\/wp\/v2\/media?parent=506"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/habett.fr\/blog\/wp-json\/wp\/v2\/categories?post=506"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/habett.fr\/blog\/wp-json\/wp\/v2\/tags?post=506"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}