-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Random header dissapearence #2083
Comments
Please post actual HTML/CSS which can be run directly, it looks you are posting some .NET markup. |
@ashkulz actuall html has no sense, it's totally dynamic - always sometinhg else, i will post sample header and "body" in gist anyway, but I thing it has no use. Plese reopen and further investigate issue, I have new clue: it seems that blank pages has the same page numbers as previous page. |
I can't investigate anything unless you post actual HTML/CSS. |
@ashkulz I will post actual html in spare time, but I was investigating those issues, I found out what was the cause of blank pages, in v0.12 there was change in wkhtml behaviour regarding page-brak-after:
earlier if there was no content after this there were no additional page rendered, now it renders page regardless whether there is additional content or not. |
Well, that is what you are requesting with your CSS ( |
@ashkulz I have updated gist with sample actual html (all markup is there). |
@ashkulz nothing I do seems to help with headers disappearing issue, I confirmed that removing --margin-top and --margin-bottom has no impact (maybe it's disappearing less often, but it's random so who can tell?). |
@ashkulz any update on this issue? |
Didn't get a time to investigate this, won't happen for a month (releasing 0.12.2 and making alpha release for 0.13) |
@ashkulz we have confirmed that header are being rendered corectlly and all requests (for headers) contains data, someting happens during building page from main content and header. I have theory that it could have someting in common with header disapearing when header is prepended with whitespaces - it could be some wierd encoding issue, something could be added before page. I double checked and all our pages are using UTF-8 encoding, but we do use some coulture specific chars in text. When can we expect some update on this issue? |
Hi, I can say that i have almost the exact same issue. When using header-html and footer-html, i see that either the header or the footer goes missing (sometimes both) when the the PDF is loaded. Its like 1st load, there is no header/footer, on 2nd load, only footer appears, 3rd load, both header and footer appear, 4th load only header, 5th, 6th, 7th works fine. I dont see any blank pages, the main content always seems to load fine, but the header and footer html just work randomly. As 0lukasz0 metioned, it does look like an issue when building the page. The header/footer or both are missed out in the page building at random. Also to point out, i have an external css link in the header and footer html. Not sure if it matters. |
I have been having the same issue. In my header/footer HTML files I used external javascript and CSS files, linked using absolute URL's; the header/footer renders sometimes when using these, but not always. I'm using externals in the main content as well (using absolute URL), no problem there. I decided that I would test that this was the problem by moving all of my data from the external files and just putting them directly in the HTML file. The problem seems to have resolved itself. Why might wkhtmltopdf be having problems with linked files in the header/footer? Does it have to do with the use of absolute URL's to link CSS/JavaScript? |
@ashkulz can we have any info on this issue? |
This issue is related to the wkhtmltopdf issue wkhtmltopdf/wkhtmltopdf#2083 It seems there is a race condition in the Javascript file loading in wkhtmltopdf 0.12.x. The subst.js file put in the header/footer of reports was not always loaded when the page was being rendered, leading to the crash of the onload="subst()" attr in the body node, leading to the non-rendering of the header/footer. Replacing the script file by its content solves the issue. Increasing the --javascript-delay of the wkhtmltopdf executable (e.g. 1000 ms instead of 200 ms, the default value) seems to solve the problem as well, but will lead to obvious performance issues. We therefore choose to put the javascript code inline, as a workaround, the time the issue is solved in wkhtmltopdf, at least. closes #3047,#5548,#6207 opw-633161
We've been having a similar issue (using 0.12.1): we were loading an external file It seems to be related to some kind of race condition, where the external JS file is not fully loaded when the footer is rendered. Perhaps this caused a JS error when the In either case we found we could work around the problem in two manners:
I haven't delved further in the source code to see how BTW, there seem to be many other issues related to the same or a similar problem: #2284, #2269, #2183, perhaps #2307 and others.. |
An example HTML/JS along with command-lines which fails some of the time would help me debug the issue. |
I updated gist with js which is generated, but to be honest I am sure problems do happen event without those javascripts (in my case they are generated and added to page if tokens like page or topage are used) |
I've been having the same issue in wkhtmltopdf 0.12.2.1. I'm using My footer uses javascript and the subst() function (declared in footer.html directly) to display the current page number and max page count. My header is static html and does not use javascript.
|
An update, I don't think the issue with >500 page PDFs has anything to do with JavaScript. I got rid of my footer.html (which used javascript for subst()) and replaced it with Now it gets to page ~1000 (as before, always at almost exactly at this number) before the header ceases to appear. The footer, generated with It's almost as if wkhtmltopdf is able to include 1000 HTML headers/footers combined before it runs into some problem? |
In order to resolve issue regarding 500 pages, configure: add these lines
and: /etc/pam.d/common-session add this line session required pam_limits.so Best Regards. |
Thanks @hbto! So in this case the problem simply comes from the default OS limits in terms of open files. |
I'll be pushing a fix which will bring back the |
I too have this issue. My theory is that it's related to the inclusion of any external JS or CSS resource. I can cause this randomness easily. I used the sample header.html from http://wkhtmltopdf.org/usage/wkhtmltopdf.txt. Simply adding the following immediately after the <link type="text/css" rel="stylesheet" href="pdf-footer.css" media="all"> If I move this CSS inclusion after the Since I wanted jQuery in mine (yeah, I know...) it was the same story again. The fix for me, since I'm using gulpjs, was to use gulp-inline (https://www.npmjs.com/package/gulp-inline/) which pulls any referenced CSS & JS files inline into the HTML document, meaning no other resources have to be loaded with the file. This is working perfectly for me so far. |
@jeff-h: it is, see the related issue which was fixed. I'm keeping this open to track why the css/js doesn't get loaded even though page is reported as loaded. |
A preview for the next release Please note that the above downloads will be removed after the |
I was having the same problem, and increasing the javascript-delay from 200 to 400 fixed it. |
@jeff-h: you shouldn't have CSS after the tag, right? |
It was a long time ago, but I'm pretty sure I was talking about the opening head tag ( |
Can you still reproduce the problem on 0.12.5? |
Wkhtmltopdf vs Reportlap |
Reportlab isn't free, and (RML) Report Markup Language™ is an XML-style language created by ReportLab. |
Closing as this seems to be resolved. Please let us know if the issue persists in |
@ashkulz, @Tomsgu : Here is the command
|
This assets has a lot of JS that is loaded by wkhtmltopdf without any reasons. Wkhtmltopdf don't like long js to load (it is why subst has been write inline) This commit allow to print again (on slowly server) several documents in the same pdf. Before this commit, the JS was not loaded before the default js-delay and so the subst function never called with as result a pdf of only 1 page. After this commit you can again print several documents in the same pdf and subst function is applied. opw-1909000 courtesy of @beledouxdenis that help to debug this error since it is only reproductible on paas server. This commit follow the same logic that commit odoo/odoo@3c61ee5 And issue wkhtmltopdf/wkhtmltopdf#2083 is not yet fixed
This assets has a lot of JS that is loaded by wkhtmltopdf without any reasons. Wkhtmltopdf don't like long js to load (it is why subst has been write inline) This commit allow to print again (on slowly server) several documents in the same pdf. Before this commit, the JS was not loaded before the default js-delay and so the subst function never called with as result a pdf of only 1 page. After this commit you can again print several documents in the same pdf and subst function is applied. opw-1909000 courtesy of @beledouxdenis that help to debug this error since it is only reproductible on paas server. This commit follow the same logic that commit 3c61ee5 And issue wkhtmltopdf/wkhtmltopdf#2083 is not yet fixed
Still an issue. |
Since update to 0.12 (now i'am using 0.12.2-dev-5dea253 - 64bit) we got wird behavior, some pages appear after last page and are blank, some pages are missing their headers.
I created gist with sample code: https://gist.github.com/0lukasz0/7b21ec0636b6a879ca6e. I tried using those command lines without margin and header spacing but problems are still there.
The text was updated successfully, but these errors were encountered: