danfickle / openhtmltopdf

An HTML to PDF library for the JVM. Based on Flying Saucer and Apache PDF-BOX 2. With SVG image support. Now also with accessible PDF support (WCAG, Section 508, PDF/UA)!
https://danfickle.github.io/pdf-templates/index.html
Other
1.93k stars 359 forks source link

Find out computed element CSS style value #971

Open smfukaya opened 6 months ago

smfukaya commented 6 months ago

Hi,

Is there a way to know (hook, subscribe, listen) before rendering (Preflight) what would be the inherited CSS styles of a inner element and somehow make on-the-fly changes to the element? For instance would somehow be possible to know that the following img inherits margin-left from p that will affect the maximum width I could set to the image in order to prevent it from going beyond the page right margin?

<style>
  p { margin-left: 5pt}
  @page{A4;margin:3cm 3cm 2cm 3cm}}
</style>
<body>
<p><img src="http://some URL" />
</p>
</body>

Best Regards, Sergio Fukaya