Revamp pdfdetach implementation to avoid repeating code paths and manual resource management.

5 jobs from revamp-pdfdetach in 9 minutes (queued for 3 seconds)
Status Job ID Name Coverage
  Build
passed #44114
build

00:04:58

passed #44115
build_clang_libcpp

00:04:48

passed #44118
build_clazy

00:05:30

passed #44116
build_gcc_49

00:08:39

passed #44117
build_mingw64_fedora

00:03:28