-
-
Notifications
You must be signed in to change notification settings - Fork 710
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
Table style "width" property ignored in latest version #666
Comments
Hello, thanks for this bug report!
I see. I think that it's a duplicate of #582, but it's supposed to be fixed in 0.42.3. Which version do you have? |
Thank you liZe. I'm using version 0.42.3. I could send you HTML code if you require it. Or an URL. |
That would be perfect. |
This is the public URL http://www.dip-badajoz.es/bop/ventana_anuncio.php?id_anuncio=111865&FechaSolicitada=2018-01-22 (the actual changes to CSS are not public still).
I just now will process with those properties. Edit: Just the same, they are discarded. :( |
External files (including CSS) return 403 (Forbidden). |
Did you mean WeasyPrint give that error? Cause you can check that all files linked are downloadable (CSS and three or four common images). If that's the case, is not a page related issue, cause any browser can download the entire page. If fact, first time I tried WeasyPrint I needed to use "wget" to download all content of the page and use WeasyPrint on the page locally :( |
Yes, I get
but downloading these files with wget or a web browser work, I suppose that there are user-agent-based rules on this server for static files. |
No, liZe, there are not user-agent specific rules. It's something related with WeasyPrint, but I don't know what. You can open any of those files without problem in any browser. I could think that is mod_security module related .... but I'm not sure just now, cause wget can download it without problems but not WeasyPrint .... so I think (maybe I'm wrong) that is an issue of WeasyPrint. Anyway, that could be something to investigate further, if I can help any way. |
OK, I'll check that too (it's strange). I've already downloaded the files and I'm trying to understand what's going on with these tables… |
It's a complex problem with many different things to say 😄. The table problemShort answers to your problem:
I'll dig deeper, but I'm afraid that it's less a real problem in WeasyPrint than a nice enhancement we'd like to have (and thus with a lower priority 😢). Table layout is not exactly specified and browsers can do almost what they want, nobody knows how it works except some prophets. I'll change the issue title if I didn't miss anything else about this problem. 403 errorThere's actually a filter on the 'Accept' header, that's why WeasyPrint get 403s. >>> from urllib.request import Request, urlopen
>>> urlopen(Request('http://www.dip-badajoz.es/bop/certificaciones_W3C.css', headers={'Accept': '*/*'}))
<http.client.HTTPResponse object at 0x7f06c962e588>
>>> urlopen(Request('http://www.dip-badajoz.es/bop/certificaciones_W3C.css', headers={}))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python3.6/urllib/request.py", line 223, in urlopen
return opener.open(url, data, timeout)
File "/usr/lib64/python3.6/urllib/request.py", line 532, in open
response = meth(req, response)
File "/usr/lib64/python3.6/urllib/request.py", line 642, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/lib64/python3.6/urllib/request.py", line 570, in error
return self._call_chain(*args)
File "/usr/lib64/python3.6/urllib/request.py", line 504, in _call_chain
result = func(*args)
File "/usr/lib64/python3.6/urllib/request.py", line 650, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 403: Forbidden Media queriesThe Presentational hintsYour tables have a lot of presentational hints that are ignored by WeasyPrint by default, including |
I realized the problem with the "only print" just along this morning. Thanks anyway. However, despite I changed loading fonts from google fonts online repo, now I have other errors from WesayPrint with "@font-face", but I will open other thread about that. Presentational hints ignored by WeasyPrint are not a problem at first sight, cause result difference is not appreciable. Curiosly, I saw all those hints without using "-p" parameter, don't know why. About using "style" attributes, we have a "must change", cause we are using "XStandard" for editing XHTML but is discontinued, so this plugin creates automatically some deprecated options like "col" etc. The priority for me is to be able to show large width tables like browsers does, adjusted to fit the page width. If that doesn't work, I'm in trouble cause I bet for WeasyPrint and finally my idea of use it instead mpdf libraries will be our only option to continue :( despite WeasyPrint is really a fantastic app. Sorry, I just read your reply (I don't know how to subscribe to this thread). |
Google
That's just a warning, but if you only have warnings about local fonts, it means that online fonts provided by Google Fonts work well.
Good to know.
I understand, it's really annoying… Give me a week, I'll spend a few hours trying to find an quick fix, but if there's nothing obvious I'm afraid mpdf is the way to go.
There's a "subscribe" button at the right of your first message in this page 😉. |
Good news: the issue is obvious: <style>
td { border: 1px solid }
</style>
<table>
<td colspan="10">test</td>
</table> I hope that the fix is obvious too. |
I'm still on it, cause I downloaded the fonts, renamed it and it's working fine on browsers, but seems weasyprint is not loading .... let me check it on monday.
I wish you find a solution, cause really weasyprint is more flexible and versatile than mpdf (that is not perfect, at all).
You have reason. In fact, I was subscribed!!! However, I'm not receiving any e-mail from the forum .... nor in the spam folder :(
But, I presume that's a particular fix for the table I send you? If that's the case, it won't work on each table we publish daily .... correct me if I'm wrong. |
I think I have, I get much better results with your tables now. Please tell me if it's better for you with the current master branch! (And good to know that WeasyPrint may be useful for you.)
No, it's a simple example that was totally broken with WeasyPrint. |
You can check your notifications page. |
Fantastic, that seems to be the solution for the notifications not working. Other forums only need to check the subscription and all is done. |
I have a doubt about it. I'm not acquainted with Python and its way of update installed applications. Should I then make something like "pip3 update weasyprint"? |
Just for a test (don't do this in production!), you can try "pip3 install --upgrade git+https://github.com/Kozea/WeasyPrint" and see if it works. This command gives you the possibility to test the latest development version. |
Well, while this problem is not solved, all is in "beta" stage, don't worry. I did what you said, but this time I tried with a larger (usually we work with this kind of tables) like the one in this:
And then stays doing something .... forever (I let it working and will tell you in 2 days) |
The warnings are right: you have different tags with the same
It's slow for me, but it works in about 1 minute. Here's my command:
Please tell me if it's forever or if it's just really long! |
It seemed to stay forever, but IT'S NOT!!! However, I can't tell if it's working cause weasyprint is ignoring my local downloaded fonts (but the HTML page is showing correctly), so the result could be correct but it's imposible to fit if not using the condensed version of the OpenSans font :( I include the first warning messages: /usr/local/lib/python3.5/dist-packages/weasyprint/document.py:33: UserWarning: There are known rendering problems with cairo < 1.15.4. WeasyPrint may work with older versions, but please read the note about the needed cairo version on the "Install" page of the documentation before reporting bugs. |
You don't have to locally install Open Sans if you're using the Google fonts provide CSS files like this one: @font-face {
font-family: 'Open Sans Condensed';
font-style: normal;
font-weight: 300;
src: local('Open Sans Condensed Light'), local('OpenSansCondensed-Light'), url(https://fonts.gstatic.com/s/opensanscondensed/v12/z7NFdQDnbTkabZAIOl9il_O6KJj73e7Ff1GhDuXMQg.ttf) format('truetype');
} As you can see, the first items of the That's why you get
and there's nothing wrong with that. WeasyPrint then tries to download the font using the third So, according to these warnings, I think that Google Fonts work for you. Maybe the |
I took my time to revise my CSS code about fonts, taking into account your clear explanation about the @font-face rule. However, apparently all is fine. The page is showing correctly all fonts (Condensed subtype too) as you'll see in attached screenshot. Actually, in fact, we try to have all resources in our server, to avoid client browser to search outside out server, so our CSS code to load required fonts is:
And, as I wrote you, apparently is working, as you can see in the first and second screenshots attached (both from FF, the first one on real view on browser and the second printing from FF to PDF). However, it seems weasyprint is ignoring the fonts, but don't know why (see the third screenshot). Maybe is ignoring the real folder where they are stored in the server. As you can see in CSS above, URL of each font is relative to the CSS file from they are loaded. So, maybe, weasyprint is trying to locate that fonts in the wrong folder. I'm going to change relative location to complete location, to try to solve this mystery. Best regards |
I finally know why: WeasyPrint doesn't support woff2 fonts, because it relies on fontconfig that doesn't support woff2. Using another format will work. |
Ups, I didn't imagine that. It's time then to search and download the ttf equivalent. Thank you. |
YOU DID IT!!! I didn't believe it (cause I'm sure it was not easy for you as you told me), so I created the PDF file at least three times, and it works perfectly!!!! Now I need to find out what where is my mistake in CSS fonts code, cause curiously now I have not condensed font in the browser!!!! But for sure is something I'm doing wrong, so I'm going to find what is just now. Then I'll test with similar (even larger) and a little more complex tables, but I'm sure all will work like a charm with weasyprint!! I'll report you next news! |
Version 43 ---------- Released on 2018-11-09. Bug fixes: * `#726 <https://github.com/Kozea/WeasyPrint/issues/726>`_: Make empty strings clear previous values of named strings * `#729 <https://github.com/Kozea/WeasyPrint/issues/729>`_: Include tools in packaging This version also includes the changes from unstable rc1 and rc2 versions listed below. Version 43rc2 ------------- Released on 2018-11-02. **This version is experimental, don't use it in production. If you find bugs, please report them!** Bug fixes: * `#706 <https://github.com/Kozea/WeasyPrint/issues/706>`_: Fix text-indent at the beginning of a page * `#687 <https://github.com/Kozea/WeasyPrint/issues/687>`_: Allow query strings in file:// URIs * `#720 <https://github.com/Kozea/WeasyPrint/issues/720>`_: Optimize minimum size calculation of long inline elements * `#717 <https://github.com/Kozea/WeasyPrint/issues/717>`_: Display <details> tags as blocks * `#691 <https://github.com/Kozea/WeasyPrint/issues/691>`_: Don't recalculate max content widths when distributing extra space for tables * `#722 <https://github.com/Kozea/WeasyPrint/issues/722>`_: Fix bookmarks and strings set on images * `#723 <https://github.com/Kozea/WeasyPrint/issues/723>`_: Warn users when string() is not used in page margin Version 43rc1 ------------- Released on 2018-10-15. **This version is experimental, don't use it in production. If you find bugs, please report them!** Dependencies: * Python 3.4+ is now needed, Python 2.x is not supported anymore * Cairo 1.15.4+ is now needed, but 1.10+ should work with missing features (such as links, outlines and metadata) * Pdfrw is not needed anymore New features: * `Beautiful website <https://weasyprint.org>`_ * `#579 <https://github.com/Kozea/WeasyPrint/issues/579>`_: Initial support of flexbox * `#592 <https://github.com/Kozea/WeasyPrint/pull/592>`_: Support @font-face on Windows * `#306 <https://github.com/Kozea/WeasyPrint/issues/306>`_: Add a timeout parameter to the URL fetcher functions * `#594 <https://github.com/Kozea/WeasyPrint/pull/594>`_: Split tests using modern pytest features * `#599 <https://github.com/Kozea/WeasyPrint/pull/599>`_: Make tests pass on Windows * `#604 <https://github.com/Kozea/WeasyPrint/pull/604>`_: Handle target counters and target texts * `#631 <https://github.com/Kozea/WeasyPrint/pull/631>`_: Enable counter-increment and counter-reset in page context * `#622 <https://github.com/Kozea/WeasyPrint/issues/622>`_: Allow pathlib.Path objects for HTML, CSS and Attachment classes * `#674 <https://github.com/Kozea/WeasyPrint/issues/674>`_: Add extensive installation instructions for Windows Bug fixes: * `#558 <https://github.com/Kozea/WeasyPrint/issues/558>`_: Fix attachments * `#565 <https://github.com/Kozea/WeasyPrint/issues/565>`_, `#596 <https://github.com/Kozea/WeasyPrint/issues/596>`_, `#539 <https://github.com/Kozea/WeasyPrint/issues/539>`_: Fix many PDF rendering, printing and compatibility problems * `#614 <https://github.com/Kozea/WeasyPrint/issues/614>`_: Avoid crashes and endless loops caused by a Pango bug * `#662 <https://github.com/Kozea/WeasyPrint/pull/662>`_: Fix warnings and errors when generating documentation * `#666 <https://github.com/Kozea/WeasyPrint/issues/666>`_, `#685 <https://github.com/Kozea/WeasyPrint/issues/685>`_: Fix many table layout rendering problems * `#680 <https://github.com/Kozea/WeasyPrint/pull/680>`_: Don't crash when there's no font available * `#662 <https://github.com/Kozea/WeasyPrint/pull/662>`_: Fix support of some align values in tables
This Issue appears as one of the first results when searching "weasyprint fit-content", so I'm writing this post in case anyone needs an alternative to Say for example that you want to center and fit to content your paragraphs, the <p> elements. This will do p
{
display: table
margin: 0 auto;
} If you just want to fit to content the same as |
I use for "table" tag this CSS properties:
All was working fine till I changed to Debian Stretch and upgraded to latest WeasyPrint. Now, tables doesn't adapt its width to the page+margin width, overflowing and being cropped at right margin.
Edit: In the terminal, weasyprint shows:
Please, could you fix it??
In the image you can see in the left how it should be displayed / printed (in fact, is printed right directly from the browser) and in the right, the output from WeasyPrint nowadays.
The text was updated successfully, but these errors were encountered: