Giter VIP home page Giter VIP logo

Comments (9)

ksaylor avatar ksaylor commented on May 29, 2024

I was able to figure out what the problem was. I had some parameters defined in the body{} that were causing the problem.

from weasyprint.

SimonSapin avatar SimonSapin commented on May 29, 2024

I donโ€™t get it. What was the problem? A syntax error that caused the rule to be ignored?

By the way, you might want to use padding-top rather than \a \a \a in content.

from weasyprint.

SimonSapin avatar SimonSapin commented on May 29, 2024

Closing as this seems solved. But Iโ€™m still curious as to what was the issue and the solution, if you feel like commenting.

from weasyprint.

ksaylor avatar ksaylor commented on May 29, 2024

Unfortunately, I didn't keep any revision control on the files, so I'm not quite sure what I changed :-( Suffice it to say, that it was my ignorance and not a problem with WeasyPrint.

from weasyprint.

ksaylor avatar ksaylor commented on May 29, 2024

By the way, thanks for the tip about padding-top!

from weasyprint.

dxiao2003 avatar dxiao2003 commented on May 29, 2024

For me it didn't work while I had "overflow: auto" on the <body> element. Removing that made the text box appear.

from weasyprint.

liZe avatar liZe commented on May 29, 2024

For me it didn't work while I had "overflow: auto" on the element. Removing that made the text box appear.

Great! body { overflow: auto } breaks the margins for some reason. Minimal case:

<style>
  @page { @top-left { content: 'test' } }
  body { overflow: auto }
</style>
body

from weasyprint.

Tontyna avatar Tontyna commented on May 29, 2024

This wasn't a bug. This was intentional ๐Ÿ˜

WeasyPrint treats all overflow values but visible like hidden.
The spec tells us that

UAs must apply the overflow-* values set on the root element to the viewport.

The viewport in our case is the PageBox (= all pages) and thus the PageBox is clipped, cutting off every single piece of content outside the page box:

if box.style['overflow'] != 'visible':
# Only clip the content and the children:
# - the background is already clipped
# - the border must *not* be clipped
rounded_box_path(context, box.rounded_padding_box())
context.clip()

Obviously, the actual intent of this viewport-overflow is to clip the body, resp. the document content. It should not devour the @page margin content.
But when we draw the MarginBoxes (being children of the PageBox) after the PageBox has clipped the context to the inner area of the page (rounded_padding_box)...

from weasyprint.

liZe avatar liZe commented on May 29, 2024

This wasn't a bug. This was intentional

For sure ๐Ÿ˜‰.

Obviously, the actual intent of this viewport-overflow is to clip the body, resp. the document content. It should not devour the @page margin content.

We have other similar workarounds to draw and clip the viewport background. The special cases needed to draw the viewport (and draw the root element a bit differently) are a mess, just like the mess created by the table wrappers. We have to live with that, I thinkโ€ฆ

from weasyprint.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.