Hi,
I'm just getting started with Prince and paged media CSS. My interest is to author content with reasonably complex layout that can be reformatted with media specific stylesheets.
Generating headers and footers only with content style attributes allows plain text to be inserted, but without the ability to insert rich XML content, the headers and footers can ony be simply styled. Using flow to divert content from the page body to the header and footer area is an ingenious solution and combining these two techniques offers some interesting possibilities.
My test page has a fairly standard web divisions of Header, Content and Footer. The content has been broken into Sections, Subsections and paragraphs. With the print stylesheet I have associated Sections with a page type of Chapter, set page breaks after each, and diverted the contents of the Header and Footer divs into the header and footer margin area to appear on every page. The structure is something like this:
So here's the first problem: the Footer only appears on the last page. I presume that Prince lays out pages as the DOM is parsed, so the footer content is not available until the last page (since it is the last div in the source). Moving the footer from the bottom of the page source to in front of the content results in the footer appearing on every page as desired. Of course having the footer appear before the content is not just a presentational issue (I can use CSS to position the footer back at the bottom of the page), it is also semantically flawed.
I encountered a similar and more problematic issue when I tried inserting some generated content into the header. I set a custom string (chapter-name) to the contents of an h3 element directly following a Section div. If I insert this value into a named span in the header like this:
I get ":: ::" in the #chapterName span, which tells me that the span is being targeted correctly, but the string is not being evaluated. If I use this style instead:
the generated content is evaluated and inserted correctly, but it's not a complete solution since I have little control over it's appearance and it breaks the header layout.
Has anyone successfully mixed generated content with richly styled headers and footers?
Finally, the background colour for pages doesn't seem to work. I have set some styles on the base page including size, margins, padding, border and background color. All style the page as expected except the page background is always white (or transparent) no matter what I set the background colour to be:
If I can find workarounds to address these issues I will definitely be using Prince for an upcoming project.
Thanks!
Scott
I'm just getting started with Prince and paged media CSS. My interest is to author content with reasonably complex layout that can be reformatted with media specific stylesheets.
Generating headers and footers only with content style attributes allows plain text to be inserted, but without the ability to insert rich XML content, the headers and footers can ony be simply styled. Using flow to divert content from the page body to the header and footer area is an ingenious solution and combining these two techniques offers some interesting possibilities.
My test page has a fairly standard web divisions of Header, Content and Footer. The content has been broken into Sections, Subsections and paragraphs. With the print stylesheet I have associated Sections with a page type of Chapter, set page breaks after each, and diverted the contents of the Header and Footer divs into the header and footer margin area to appear on every page. The structure is something like this:
<header>
<content>
<section>
<subsection>
...
</section>
...
<section>
<subsection>
...
</section>
</content>
<footer>
So here's the first problem: the Footer only appears on the last page. I presume that Prince lays out pages as the DOM is parsed, so the footer content is not available until the last page (since it is the last div in the source). Moving the footer from the bottom of the page source to in front of the content results in the footer appearing on every page as desired. Of course having the footer appear before the content is not just a presentational issue (I can use CSS to position the footer back at the bottom of the page), it is also semantically flawed.
I encountered a similar and more problematic issue when I tried inserting some generated content into the header. I set a custom string (chapter-name) to the contents of an h3 element directly following a Section div. If I insert this value into a named span in the header like this:
#header h3 #chapterName { content: ":: " string(chapter-name) " ::"; }
I get ":: ::" in the #chapterName span, which tells me that the span is being targeted correctly, but the string is not being evaluated. If I use this style instead:
@page chapter {
@top-right {
content: ":: " string(chapter-name) "::";
}
}
the generated content is evaluated and inserted correctly, but it's not a complete solution since I have little control over it's appearance and it breaks the header layout.
Has anyone successfully mixed generated content with richly styled headers and footers?
Finally, the background colour for pages doesn't seem to work. I have set some styles on the base page including size, margins, padding, border and background color. All style the page as expected except the page background is always white (or transparent) no matter what I set the background colour to be:
@page {
size: A4; margin: 40mm 15mm 20mm; padding: 2em 0;
background: yellow; border: 1px solid black;
@top { content: flow(header); vertical-align: bottom; }
@bottom { content: flow(footer); vertical-align: top; }
}
If I can find workarounds to address these issues I will definitely be using Prince for an upcoming project.
Thanks!
Scott