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

ContentOperationNotPermittedError #1937

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

Comments

6 participants
@momolog
Copy link

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

This comment has been minimized.

Copy link

commented Jun 29, 2015

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

This comment has been minimized.

Copy link
Member

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

This comment has been minimized.

Copy link
Author

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

This comment has been minimized.

Copy link
Member

commented Jun 30, 2015

See this comment for an explanation.

@KlimczakM

This comment has been minimized.

Copy link

commented Apr 28, 2016

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

@ashkulz

This comment has been minimized.

Copy link
Member

commented Apr 29, 2016

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

@r3mafe

This comment has been minimized.

Copy link

commented Aug 26, 2016

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

This comment has been minimized.

Copy link

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
You can’t perform that action at this time.