Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error messages about pandoc --to pdf #1155

Closed
Toxaris opened this issue Feb 12, 2014 · 10 comments · Fixed by #4815
Closed

Improve error messages about pandoc --to pdf #1155

Toxaris opened this issue Feb 12, 2014 · 10 comments · Fixed by #4815

Comments

@Toxaris
Copy link

Toxaris commented Feb 12, 2014

Pandoc can produce pdfs, but there is no pdf writer. Instead, in order to produce pdfs, you have to use the latex writer with an output file name that ends in .pdf. I understand the technical reasons for this behavior. Unfortunately, the user interface is not perfect if people accidently use a --to pdf flag:

`>echo hello | pandoc --to pdf
pandoc: Unknown writer: pdf

> echo hello | pandoc --to pdf -o hello.pdf
pandoc: cannot produce pdf output with pdf writer

The first error message suggests that pandoc cannot produce pdfs, and the second error message suggests that there is a pdf writer, but it is broken. Both error messages fail to help users achieve their goal, presumably to create a pdf with pandoc.

I see two options for how to improve the behavior:

  1. These error messages could explain how to produce a pdf. Approximately:

    Unknown writer: pdf.
    To create a pdf with pandoc, use the latex writer and an output file name:
    pandoc --to latex -o filename.pdf
    
  2. These invocations could try to produce a pdf, essentially "faking" a pdf writer. The first invocation would have to fail because there's no output file name:

    `>echo hello | pandoc --to pdf
    pandoc: Specify output file name for pdf with -o filename.pdf
    

    The second invocation would have the same as pandoc --to latex -o hello.pdf.

@KurtPfeifle
Copy link

If you want PDF output, you do not need any --to. You only need an output filename with a .pdf suffix: -o output.pdf. The only variable is that you may use a different latex engine: --latex-engine=xelatex or --latex-engine=lualatex. By default (if you do not name an alternative latex-engine), it will behave as if you used --latex-engine=pdflatex.

But I agree, the error message that pops up if you use --to=pdf can be improved and made more clear.

@Toxaris
Copy link
Author

Toxaris commented Feb 12, 2014

@KurtPfeifle: Thanks for the extra info. Can you propose short and helpful error messages for the two example invocations above?

@KurtPfeifle
Copy link

echo hello | pandoc --to pdf
  pandoc: Unknown writer: pdf
  pandoc: To create a PDF, specify output file with suffix '.pdf'. Example: '-o filename.pdf'.

@Toxaris
Copy link
Author

Toxaris commented Feb 12, 2014

Given @KurtPfeifle's error message, I would try next:

echo hello | pandoc --to pdf -o filename.pdf
  pandoc: cannot produce pdf output with pdf writer

@KurtPfeifle
Copy link

echo hello | pandoc --to pdf
  pandoc: Unknown writer: pdf
  pandoc: To create a PDF, do not use '--to pdf'. 
  pandoc: For PDF output, simply specify output file with suffix '.pdf'. 
  pandoc: Example: 'pandoc -o filename.pdf [...other options...]'.

@jgm jgm closed this as completed in 11120d6 Apr 6, 2014
@jgm
Copy link
Owner

jgm commented Apr 6, 2014

@Toxaris - thanks for the suggestion.

@mariussoutier
Copy link

I guess this got lost somewhere, because right now the error message is pretty confusing: cannot produce pdf output from pdf

@jgm
Copy link
Owner

jgm commented Aug 1, 2018

@mariusoutier What are you doing to get that message, and what version of pandoc are you using?

@mariussoutier
Copy link

pandoc --from markdown --to pdf --output gs.pdf produces the confusing error message. pandoc --from markdown --output gs.pdf works as expected.

@jgm jgm reopened this Aug 2, 2018
@jgm
Copy link
Owner

jgm commented Aug 2, 2018

OK, I see. This makes sense if you understand what's going on internally -- pandoc generates latex, html, or ms and converts that to a pdf -- but I agree it's confusing.

mb21 added a commit to mb21/pandoc that referenced this issue Aug 3, 2018
@jgm jgm closed this as completed in #4815 Aug 3, 2018
jgm pushed a commit that referenced this issue Aug 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants