Subject: bug#8519: 24.0.50; doc-view: allow pdftotext -layout instead of -raw

From: Juri Linkov <[email-masked]>
Date: Fri, 01 Jul 2011 00:57:45 +0300

> doc-view supports using pdftotext on ttys.
> Unfortunately it is hard-coded to pass -raw.
> I would prefer to pass -layout.
>
> Please modify doc-view to allow me to support something like
>
>     (setq doc-view-pdftotext-program-args '("-layout" "-nopgbrk"))

I came across the same need and found this bug report.

I think doc-view should also support other free software
that processes PDF files:

1. pdftk

pdftk is able to extract the PDF metadata (title, author, bookmarks, etc.),
e.g.

    pdftk file1.pdf dump_data output file1.txt

So for a large PDF document, doc-view could present the
Table of Contents where the user can navigate to the selected page,
and then convert only displayed pages instead of all pages
that is terribly slow for a 1000-page document.

pdftk also can prepare the PDF text for editing in emacs.
>From `man pdftk':

  -compress useful when you want to edit PDF code
            in a text editor like vim or emacs.

   Uncompress PDF page streams for editing the PDF
   in a text editor (e.g., vim, emacs):

       pdftk doc.pdf output doc.unc.pdf uncompress

This feature could be used after typing `C-c C-c'.

Since pdftk is dependent on Java, doc-view should not require it
and should be able to detect the installed PDF processing programs
(with e.g. `(executable-find "pdftk")') and select one of them
according to the user's priority list.

2. A better program is `qpdf'. It has no problems mentioned above.
So doc-view should also detect the availability of
`(executable-find "qpdf")' as well and provide the same option for its
command line arguments (and use all features relevant to doc-view).

3. Using the PDF rendering library `poppler,' it's possible
to implement in Emacs a PDF viewer like `apvlv' for Vim.