Forum How do I...?

How to apply styles in iframes?

barto
Hi,
I am creating a pdf file from a html file using Prince 14.3. This html file contains another html file using an iframe tag. The pdf sohws the iframe content, but no style is applied to the iframe. In the Prince user GUide Help it is said that "However there may be some subtleties required to get the correct size and styling of content within iframe elements." Can it be done?
Thanking you in advance,
Barto
princexml command
prince.exe" index.html -o output.pdf

index.html
<body>
  <h1>iframe test</h1>
  <iframe src="sample.html" style="border: black 1px solid;"></iframe>
</body>

sample.html
<head>
  <meta charset="utf-8">
  <title>Sample</title>
  <style>
    body {
      background-color: lightblue;
    }
  </style>
</head>

<body>
  <h1>Sample</h1>

  <p>Esse laboris officia voluptate do proident.</p>
</body>

  1. index.html0.2 kB
  2. output.pdf38.5 kB
  3. sample.html0.3 kB
mikeday
The background seems to work when applied to the h1 within the iframe, just not the body element, whose style is reset for reasons that escape me at the moment.

A temporary workaround would be to add a <div> wrapping all the content within the iframe and apply the relevant styling to that.
mikeday
We have now fixed this issue in the latest build of Prince.