ContentOperationNotPermittedError #1937

Closed
momolog opened this Issue Sep 1, 2014 · 8 comments

Projects

None yet

6 participants

@momolog
momolog commented Sep 1, 2014

When running wkhtmltopdf 0.12.1 (with patched qt) like this

wkhtmltopdf --page-size A4 --encoding UTF-8 --orientation landscape /tmp/test.html /tmp/output.pdf

on a document containing

<img src="http://example.com/test.jpg" />

(a non-existent image), one gets the following output

Loading pages (1/6)
Warning: Failed to load http://example.com/test.jpg (ignore)
Counting pages (2/6)
Resolving links (4/6)
Loading headers and footers (5/6)
Printing pages (6/6)
Done

and a status code of 0 (success), a PDF is generated.

If, however the URL of the image gets slightly changed to something like

<img src="http://example.com/test.jpg?332534" />

(only added a random query param) one gets the following output

Loading pages (1/6)
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: ContentNotFoundError

and a status code of 1 (error). A PDF is generated nonetheless, but wrapper code will assume a non-recoverable error.

This is clearly very confusing behaviour and imho. a bug.

@zealfire

I was too getting same error. On further investigation I came to conclusion that inclusion of base tag in head section was cause of problem. I was writing a code like this:

<base href=" \path\to\file" \>
which was causing Exit with code 1 due to network error: ContentOperationNotPermittedError but after removing it the error was removed. Any reasons for this?

@ashkulz
Member
ashkulz commented Jun 30, 2015

@momolog: the reason is simple, in the latter case one cannot guess that this is a request for an image just looking at the URL and hence we consider that it is a more severe error. This is a duplicate of #1855.

@ashkulz ashkulz closed this Jun 30, 2015
@ashkulz ashkulz added the Duplicate label Jun 30, 2015
@momolog
momolog commented Jun 30, 2015

@ashkulz Thanks for pointing out, that this is a duplicate.
I fail to see however, why a query parameter would change the expectation of what type of resource
http://example.com/test.jpg?332534
will yield.

@ashkulz
Member
ashkulz commented Jun 30, 2015

See this comment for an explanation.

@KlimczakM

Hello guys, any progress there by any chance? This is still troublesome...

@ashkulz
Member
ashkulz commented Apr 29, 2016

@KlimczakM: see the linked issue, it requires changes in Qt/WebKit.

@r3mafe
r3mafe commented Aug 26, 2016 edited

I had similar problem: generating PDF from within PHP was working fine, but a direct execution of wkhtmltopdf command in a console was throwing ContentOperationNotPermittedError.

The thing is - I was using url with user token, that later was used inside the code to authenticate on the server:
https://example.com/pdf/$2y$08$FyRmY8aR88AgjRY0DFbFCv===DD0W8L6D...

And I found out that on some OS that address was not interpreted right and the token was malformed by the time in got to my js-script.

So, changing $ to %24 and = to %3D did the trick.

Maybe it will help someone.

@Hubro
Hubro commented Oct 31, 2016

I also got this error today. In my case it was because I'd made a change to my nginx config that blocked access to the website in question for the server that wxhtmltopdf was running on. Basically, wkhtmltopdf got a "401 Forbidden" when trying to open the URL, and that resulted in this error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment