Skip to content

Offer an alternative to pdftk

(copy-paste from bitbucket-pr-52)

Summary: pdftk relies on GCJ which has been dead for a while (gcc 7 does not contain GCJ) and also because gcc 5 has a bug (fixed in macports) which has not fixed in Homebrew's gcc 5 and prevents building PDFtk. To be fair, I tried to apply the patch to Homebrew's flavoured gcc but waiting for 1.5 hours for gcc to recompile is such a pain that I gave up... Instead, I propose to rely on qpdf and poppler. Pdftk would still be on by default. I spotted three places where pdftk is used:

  • AMC-imprime.pl where qpdf can be used as a replacement (contrary to pdftk, qpdf does not drop the form fields and support multi-slicing)
  • AMC-read-pdfform.pl: because the only option was pdftk, I wrote a small C program (pdfformfields.c) to replace the form field reading. pdfformfields behaves exactly like the pdftk dump_data_fields_utf8 command (I made sure of it).
  • AMC-getimages.pl already can use pdfimages from poppler instead of pdftk
  • also pdftk is used during the build but using 'dist' tarballs eliminates this need

TODO:

  • AMC-getimages.pl: offer an alternative to pdftk to split the PDF file into single-pages PDF, because pdfimages is not exactly the same and is disabled when passing the --force-convert option. However, qpdf --split-pages should do the job.
  • Add an option qpdf to the configuration menu (see line 917 of AMC-gui.pl.in), and choose between pdftk+NA and qpdf for project_extract_with (line 2280), depending on the value of $config->get("print_extract_with") and the availability of pdftk and qpdf.
  • AMC-read-pdfform.plAMC-pdfformfields has to be called with auto-multiple-choice pdfformfields
  • Add another configutaion option GCC_POPPLER or so for the flags to be added to compile AMC-pdfformfields
  • Add tests so that we make sure everything works with either qpdf or the others?
Edited by Maël Valais

Merge request reports