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

Don't repeat background images when it's not needed #238

Closed
diethardsteiner opened this issue Feb 13, 2015 · 7 comments

Comments

3 participants
@diethardsteiner
Copy link

commented Feb 13, 2015

I just tested my stylesheet on Fedora and Mac OS X and the rendering is different. For the top left margin box I have a background image and background color defined. The preview via weasyprint.navigator is the same on both OSes, however the actual PDF output not: On Fedora, the background color is applied to the whole box, whereas on Mac OS X I see the background color only behind the background image. This seems to be related to the css property background-size.

Here is the CSS I apply:

@top-left {
        width: 70%;
        content: "";
        background-color: rgba(42, 201, 80, 0.220);
        background-image: url('images/logo_v4.png');
        background-size: contain;
        background-repeat: no-repeat;
        background-position: left;
        border-bottom: solid green;
    } 
@SimonSapin

This comment has been minimized.

Copy link
Member

commented Feb 13, 2015

Do you use the same PDF viewer on both systems? If not, try view each PDF file on the other system to see if the files are actually different or just rendered differently.

@diethardsteiner

This comment has been minimized.

Copy link
Author

commented Feb 13, 2015

Thanks a lot for your reply! Yes, you are correct, it is actually a problem related to the PDF viewer. On Fedora I use 'Document Viewer' and on Mac OS X 'Preview'. So which one is correct then? Is Preview at fault here?

I also tried to read up a bit more on the CSS definitions and adjusted the CSS a bit:

        background: url('images/logo_v4.png'), rgba(42, 201, 80, 0.220);
        background-repeat: no-repeat, repeat;
        background-position: left center, left;
        background-size: contain

however that didn't really help.

Based on your experience, what is the best cross platform PDF viewer?

@diethardsteiner

This comment has been minimized.

Copy link
Author

commented Feb 17, 2015

Closing the issue as this seems to be Mac OS X 'Preview' related - although I cannot confirm it with 100% certainty.

@SimonSapin

This comment has been minimized.

Copy link
Member

commented Feb 17, 2015

The same PDF file is rendered differently by different PDF viewers, so there is a PDF interoperability issue here independently of WeasyPrint.

That said, the way WeasyPrint paints background images (using a repeating pattern even for background-repeat: no-repeat) is a bit unusual and has likely caused other issues before. (See #232 and #222 for example.) WeasyPrint could potentially be changed to generate a more straightforward PDF file, which would likely work around this issue.

@diethardsteiner

This comment has been minimized.

Copy link
Author

commented Feb 17, 2015

Ok, thanks for your feedback. Reopened ticket in hope WeayPrint's background image logic will be optimised.

@SimonSapin

This comment has been minimized.

Copy link
Member

commented Feb 17, 2015

“Optimized” is a strong word. It’s more like “do something kinda differently at seemingly random in the hope that maybe something different will happen” :)

@diethardsteiner

This comment has been minimized.

Copy link
Author

commented Feb 17, 2015

Ok :)

@liZe liZe changed the title Page margin box: different behaviour on different OSes Don't repeat background images when it's not needed Aug 14, 2015

@liZe liZe added the feature label Aug 14, 2015

@liZe liZe added this to the 48 milestone Jun 2, 2019

@liZe liZe closed this in 8499379 Jun 2, 2019

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.