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

--css option doesn't work with wkhtmltopdf 0.12.6 #6474

Closed
junkblocker opened this issue Jun 20, 2020 · 6 comments
Closed

--css option doesn't work with wkhtmltopdf 0.12.6 #6474

junkblocker opened this issue Jun 20, 2020 · 6 comments

Comments

@junkblocker
Copy link

junkblocker commented Jun 20, 2020

Steps to reproduce

% printf "===\nfoo\n===\n\nbar" > in.rst
% echo > test.css
% pandoc -f rst -t html5 --css=test.css -o out.pdf in.rst
Loading pages (1/6)
Warning: Blocked access to file /private/tmp/test.css
Error: Failed to load about:blank, with network status code 301 and http status code 0 - Protocol "about" is unknown
Counting pages (2/6)
Resolving links (4/6)
Loading headers and footers (5/6)
Printing pages (6/6)
Done
Exit with code 1 due to network error: ProtocolUnknownError
Error producing PDF.

% pandoc -v
pandoc 2.9.2.1
Compiled with pandoc-types 1.20, texmath 0.12.0.1, skylighting 0.8.3.2
Default user data directory: /Users/xxx/.local/pandoc or /Users/xxx/.pandoc
Copyright (C) 2006-2020 John MacFarlane
Web:  https://pandoc.org
This is free software; see the source for copying conditions.
There is no warranty, not even for merchantability or fitness
for a particular purpose.

The breakage does not happen when --css option is not supplied.

% pandoc -f rst -t html5 -o out.pdf in.rst
Loading pages (1/6)
Counting pages (2/6)
Resolving links (4/6)
Loading headers and footers (5/6)
Printing pages (6/6)
Done
@mb21
Copy link
Collaborator

mb21 commented Jun 21, 2020

Works on my macOS 10.15 with wkhtmltopdf 0.12.5

What's your versions?

The problem is this:

Warning: Blocked access to file /private/tmp/test.css

seems wkhtmltopdf is trying to write temp files there...

@junkblocker
Copy link
Author

I am on latest macOS 10.15.5.

% uname -a
Darwin abcd.local 19.5.0 Darwin Kernel Version 19.5.0: Tue May 26 20:41:44 PDT 2020; root:xnu-6153.121.2~2/RELEASE_X86_64 x86_64

I have installed wkhtmltopdf via homebrew

% wkhtmltopdf -V
wkhtmltopdf 0.12.6 (with patched qt)

The failure occurs no matter where the css file is.

@jgm
Copy link
Owner

jgm commented Jun 21, 2020

I can reproduce this with dev version of pandoc on latest macOS, with same version of wkhtmltopdf. I infer from my own error message that /private/tmp is your working directory.

In any case, the message is definitely coming from wkhtmltopdf, which pandoc is running in a subprocess.

@jgm
Copy link
Owner

jgm commented Jun 21, 2020

It can be reproduced completely outside pandoc, so I suggest you report the issue to wkhtmltopdf. Let us know if you find out anything helpful.

% cat in.html 
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
<head>
  <title>foo</title>
  <link rel="stylesheet" href="test.css" />
</head>
<body>
<h1 class="title">foo</h1>
<p>bar</p>
</body>
</html>

% wkhtmltopdf in.html in.pdf
Loading pages (1/6)
Warning: Blocked access to file /Users/jgm/src/pandoc/test.css    
Error: Failed to load about:blank, with network status code 301 and http status code 0 - Protocol "about" is unknown
Counting pages (2/6)                                               
Resolving links (4/6)                                                       
Loading headers and footers (5/6)                                           
Printing pages (6/6)
Done                                                                      
Exit with code 1 due to network error: ProtocolUnknownError

@junkblocker
Copy link
Author

Got the answer from wkhtmltopdf folks - wkhtmltopdf/wkhtmltopdf#4735 . 0.12.6 had the breaking change https://github.com/wkhtmltopdf/wkhtmltopdf/releases/tag/0.12.6 . Needs --enable-local-file-access flag added to work.

@mb21 mb21 changed the title --css option broken --css option doesn't work with wkhtmltopdf 0.12.6 Jun 22, 2020
@jgm jgm closed this as completed in 76fc51f Jun 22, 2020
@tpo
Copy link

tpo commented Sep 1, 2021

use pandoc --pdf-engine-opt=--enable-local-file-access when you get this error. Mind the meaning of enable-local-file-access

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

No branches or pull requests

4 participants