I want to save an email receipt as a PDF. I type a
and v
(for Action and View as PDF) and get Wrong type argument: stringp, nil
. How can I save a message as a PDF file?
With wkhtmltopdf installed, here's a function that saves the PDF to your Desktop automatically:
(defun mu4e-action-save-to-pdf (msg)
(let* ((date (mu4e-message-field msg :date))
(infile (mu4e~write-body-to-html msg))
(outfile (format-time-string "%Y-%m-%d%H%M%S.pdf" date)))
(with-temp-buffer
(shell-command
(format "wkhtmltopdf %s ~/Desktop/%s" infile outfile) t))))
(add-to-list 'mu4e-view-actions '("Save to PDF" . mu4e-action-save-to-pdf) t)
-
@mmorin I replaced the
call-process-shell-command
function withshell-command
. Can you try again. You could also replace it withprint
to examine the output. – jagrg Jul 1 '19 at 12:25 -
I asked this follow-up question about including message headers in the PDF. – miguelmorin Feb 25 '20 at 12:11
-
I see the From, To, Date, and Subject header fields in the PDF. I'm not sure what the issue is. – jagrg Feb 27 '20 at 2:00
-
I included a picture of the PDF output from your code in that other thread. I have
mu4e-mu-version 1.2.0
, how about you? The functionmu4e~write-body-to-html
does not mention if headers are included. Does the body of a mu4e message include the headers? – miguelmorin Feb 27 '20 at 11:58 -
1Try the
mu4e~write-body-to-html
function in the master branch and see if that works for you. I'm using mu version 1.3.4 C. – jagrg Feb 27 '20 at 12:38
To get the same result, but with an additional step, I suggest to view the email in your web browser with (add-to-list 'mu4e-view-actions '("ViewInBrowser" . mu4e-action-view-in-browser) t)
and to then print it to a pdf file.
mu4e-msg2pdf
, I get:is a variable defined in ‘mu4e-actions.el’. Its value is nil
. I installedmu
withbrew install mu --with-emacs
and runningbrew upgrade --with-emacs mu
givesError: invalid option: --with-emacs
. How do I reinstallmu
withmu4e
ormsg2pdf
? Or how do I get the file location of the current message on disk? – miguelmorin Jun 24 '19 at 17:09(add-to-list 'mu4e-view-actions '("ViewInBrowser" . mu4e-action-view-in-browser) t)
. Do you want to write an answer? – miguelmorin Jun 26 '19 at 14:21