[publican-list] Possible alternative to FOP!

Jeff Fearn jfearn at redhat.com
Tue Aug 30 03:13:10 UTC 2011


Hi Peter, thanks for your input! I'm not sure wkhtmltopdf supports 
widows & orphans or much of the CSS3 pagination yet. I hope to get time 
to test your suggestions soon!

FYI FOP itself does a fairly poor job of handling widows and orphans, 
particularly when combined with content longer than a page. e.g. if you 
want to use keep-together with content longer than a page, you are in 
for a world of pain :(

The bright side, as I see it, is that the upstream for QT has active 
contributions on layout from Apple and Google, particularly for the CSS3 
pagination, so things should get better sooner that they will for FOP 
... hopefully ;)

Cheers, Jeff.

On 08/27/2011 12:15 AM, Peter Moulder wrote:
> It happens that I've recently been experimenting with using an HTML formatter
> to get pdf myself.  I haven't been using wkhtmltopdf, but at least I can share
> some stylesheet things I've tried.
>
>
> On Fri, Aug 26, 2011 at 04:29:13PM +1000, Jeff Fearn wrote:
>
>> Here is a PDF with prettier footers!
>>
>> http://fedorapeople.org/~jfearn/Red_Hat_Enterprise_Linux-6-Installation_Guide-en-US-TEST.pdf
>
> At the end of page 30 is an orphan, followed by a widow on the next page.
> This is a bit surprising, as the initial value for 'widows' and 'orphans' is 2.
> Try adding
>
>    * { widows: 2 !important; orphans: 2 !important; }
>
> but it may just be that wkhtmltopdf doesn't yet support 'widows' and 'orphans'.
>
> Page 31 ends with a header.  Make sure you have
>
>    h1,h2,h3,h4,h5,h6 { page-break-inside: avoid; page-break-after: avoid; }
>
> to avoid that.
>
>> Thanks to [Ryan] Lerch for investigating how to do this, still needs
>> some tweaks, but we have a pretty good handle on how to customise
>> page footers and headers now!
>
> I append the stylesheet I've been using, in case it's helpful.  It uses
> css3-page and css3-gcpm stuff to get page headers / footers / table-of-contents
> stuff like in the existing fop pdf output; but that part of the stylesheet is
> completely untested, and I don't know what page/gcpm stuff wkhtmltopdf
> supports.
>
> Oh, also, I wrote this stylesheet based on a document not split into parts
> (i.e. Part I etc.), and it still needs a few changes in the selectors to work
> with documents that are split into parts.  I'm guessing that you'll just use
> the stylesheet for ideas rather than using literally, so I'll just send as is.
>
> Note that I made the page numbers and choice of header text mostly follow the
> pattern used in the existing fop-produced documents, which differs from
> what's done in the above sample in a couple of ways: roman numerals for first
> few pages then starting again from 1 after the preface; no header/footer for
> page i; page headers are chapter (left page) and section (right page), but
> blank headers for the appendices.  One thing I didn't reproduce was the
> unique header for the first page of a chapter.
>
> Note too that I've forced use of svg instead of png for the note / warning /
> important icons; though I've used relative URLs, so the paths might need
> tweaking.
>
> [Ideally all of the HTML/EPUB output would use the SVGs too, so that they can
>   be printed or zoomed.  I see that some Publican-produced HTML files already
>   use SVG images, at least for title_logo.svg.]
>
> It currently uses !important everywhere just because I was using it as a user
> stylesheet.
>
> pjrm.
>
>
> /* The preface part of the document uses roman-numeral page numbers,
>   * and the page numbers start again from 1 after the preface.
>   * Appendices differ only in that there's no header text (just a border).
>   */
>
> @page {
> 	counter-increment: main-page;  /* Overridden in :first and preface pages. */
>
> 	@top-center {
> 		text-align: inherit;  /* Override UA default stylesheet of text-align:center to inherit from page context (left or right). */
> 		border-bottom: 0.5pt solid black;
> 		margin-bottom: 16.5pt;
> 		content: "";
> 	}
>
> 	@bottom-center {
> 		text-align: inherit;
> 		margin-top: 2pt;
> 		border-top: 0.5pt solid black;
> 		content: counter(main-page);
> 	}
> }
>
> @page :left {
> 	margin: 73pt 87pt 46pt 54pt;
> 	text-align: left;
> }
>
> @page :right {
> 	margin: 73pt 54pt 46pt 87pt;
> 	text-align: right;
> }
>
> @page :first {
> 	counter-increment: preface-page;
>
> 	@top-center {
> 		content: none;
> 		/* And thus no border. */
> 	}
>
> 	@bottom-center {
> 		content: none;
> 	}
> }
>
> @page preface {
> 	counter-increment: preface-page;
>
> 	@bottom-center {
> 		content: counter(preface-page, lower-roman);
> 	}
> }
>
> @page preface:left {
> 	@top-center { content: fixme need longer example to know the rule; }
> }
>
> @page chapter:left {
> 	@top-center {
> 		content: string(left-page-header);
> 	}
> }
>
> @page chapter:right {
> 	@top-center {
> 		content: string(right-page-header);
> 	}
> }
>
> .book>div.titlepage, .book>div.toc, .book>div.preface { page: preface; }
>
> .book>div.chapter { page: chapter; }
>
> .book>div.appendix { page: appendix; }
>
> div.chapter h2 { set-string: left-page-header content(); }
>
> div.section h2 { set-string: right-page-header content(); }
>
>
> body {
> 	margin: 0 !important;
> 	font-size: 9pt !important;
> }
>
> body:lang(zh) {
> 	font-size: 12pt !important;
> }
>
> .programlisting {
> 	font-size: 8pt !important;
> }
>
> .screen {
> 	font-size: 8pt !important;
> }
>
> div.admonition_header {
> 	margin-top: -35px !important;
> 	padding-left: 44pt !important;
> }
>
> div.chapter, div.appendix, div.preface, div.part {
> 	page-break-before: always;
> }
>
> /* Override the above .chapter, .section etc. rules for the ones in the table-of-contents. */
> .toc * {
> 	page-break-before: auto;
> }
>
> /* Use *.svg instead of *.png for warning/note/important icon. */
> div.warning:before {
> 	content: url(../images/warning.svg) !important;
> }
> div.note:before {
> 	content: url(../images/note.svg) !important;
> }
> div.important:before {
> 	content: url(../images/important.svg) !important;
> }
>
> div.warning, div.note, div.important {
> 	padding-top: 0pt !important;
> 	page-break-inside: avoid;
> }
>
> dt {
> 	page-break-after: avoid;
> }
>
> ul {
> 	padding-left: 0 !important;
> 	list-style-type: disc;
> }
>
> img {
> 	max-width: 444px;
> }
>
> /* Table of Contents page numbers. */
>
> .toc span.preface a:after {
> 	content: " " leader(dotted) " " target-counter(attr(href, url), preface-page, lower-roman);
> }
>
> .toc span.chapter a:after,
> .toc span.appendix a:after {
> 	content: " " leader(dotted) " " target-counter(attr(href, url), main-page);
> }
>
> _______________________________________________
> publican-list mailing list
> publican-list at redhat.com
> https://www.redhat.com/mailman/listinfo/publican-list
> Wiki: https://fedorahosted.org/publican


-- 
"Reply All" why you shouldn't use it: 
http://www.emailreplies.com/#12replytoall




More information about the publican-list mailing list