Subject: Re: bug#44338: 27.1; EWW can't download and view pdf

From: Nicholas Harrison <[email-masked]>
Date: Tue, 3 Nov 2020 16:52:40 -0700

I'll make a couple more comments on the original problem I explained. It
looks like you may have identified additional improvements in the process.

I believe the first problem for me is that both mailcap-mime-data
and mailcap-user-mime-data are nil. This causes the `error in process
filter: mailcap-view-mime: Symbol’s function definition is void: nil` and
makes the pdf download and appear in Fundamental mode. This occurs whether
I will be using doc-view-mode or pdf-view-mode. I'll use DocView for the
rest of this example.

1. emacs -Q
2. M-x eww
3. https://www.gnu.org/software/emacs/manual/pdf/emacs-xtra.pdf

This results in the error message and the following:

This can be (partially) corrected by running the following code before the
steps 2 and 3:
(add-to-list 'mailcap-user-mime-data
             '((type . "application/pdf")
               (viewer . doc-view-mode)))

This chooses a view mode for the pdf but that brings the second problem.
This selects the default encoding of raw-text and the conversion fails:

Instead I choose doc-view-mode manually for the eww pdf buffer:

Then selecting binary for the encoding finally gets a viewable pdf:

I hope this is in some way helpful.

Nicholas

On Sat, Oct 31, 2020 at 7:43 AM Basil L. Contovounesios <[email-masked]>
wrote:

> Nicholas Harrison <[email-masked]> writes:
>
> > Using the EWW browser, I can navigate around to webpages, but navigating
> > to a pdf fails. It appears to download an unreadable pdf. Downloading
> > and viewing the pdf manually in emacs (pdf-view-mode) works fine.
> >
> > I've tried these solutions to no avail:
> > - Adding "application/pdf; emacsclient %s" to a ~/.mailcap file. This
> >   makes the process hang indefinitely.
> > - Running the following elisp code:
> >   `(add-to-list 'mailcap-user-mime-data
> >                  '((type . "application/pdf")
> >                    (viewer . pdf-view-mode)))`
> >   This doesn't seem to have an effect.
>
> Seems to have been fixed on master:
>
> 1. emacs -Q
> 2. M-x eww RET https://www.gnu.org/software/emacs/manual/emacs.html RET
> 3. C-s extra pdf RET RET
>
> This opens the "Specialized Emacs Features" manual in a *eww pdf* buffer
> in doc-view-mode.
>
> With PDF Tools and the mailcap-user-mime-data setting above installed,
> it opens in pdf-view-mode instead.
>
> I'm surprised the setting for mailcap-user-mime-data is needed though,
> since pdf-view-mode appears before doc-view-mode in both
> mailcap-mime-data and my version of auto-mode-alist.
>
> Lars?
>
> --
> Basil
>