Widow/Orphan control in PDF

This forum is for all Flare issues related to PDF, eBook, Microsoft Word, Adobe FrameMaker, XPS, and XHTML book targets.
Post Reply
echopraxia
Propeller Head
Posts: 13
Joined: Wed Aug 29, 2012 11:38 am

Widow/Orphan control in PDF

Post by echopraxia »

I have a page with several tables, and I can't seem to figure out how to link the paragraph above to the table below so that they do not end up on different pages. I can't seem to figure out how to put in a page break, though tables themselves have widow/orphan control on them and are working fine and generating page breaks where appropriate for a table-only. Any help on this would be greatly appreciated. I have multiple audiences with condition tags all over the place so manually formatting this each time I need to generate it is a horrible pain.
sfoley
Propeller Head
Posts: 92
Joined: Mon May 05, 2008 5:00 pm

Re: Widow/Orphan control in PDF

Post by sfoley »

echopraxia wrote:I have a page with several tables, and I can't seem to figure out how to link the paragraph above to the table below so that they do not end up on different pages. I can't seem to figure out how to put in a page break, though tables themselves have widow/orphan control on them and are working fine and generating page breaks where appropriate for a table-only. Any help on this would be greatly appreciated. I have multiple audiences with condition tags all over the place so manually formatting this each time I need to generate it is a horrible pain.
Unless you take the time to do manual formatting, you're almost always going to have a few bad page breaks in any sufficiently large document. I've learned to just put up with them, since few people actually print my documentation and fewer still would bother to complain.

That being said, you can set some sane defaults using CSS (if you haven't already.) There are several relevant properties, and while you can apply them to any element to get the look you want, I generally start with these for any new project:

Code: Select all

@media pdf {
	* {
		mc-hyphenate: never;
		mc-short-line-method: tighten-loosen;
		mc-short-line: 4;
	}

	h1,h2,h3,h4,h5,h6,th,p.TOC1,p.ListItem {
		page-break-after: avoid;
	}

	p,td,ol,ul {
		orphans: 3;
		widows: 3;
	}
    
	li,td {
		page-break-inside: avoid;
	}
}
What all that does:
- Turns off hyphenation
- Reduces the occurrence of lines with very little text
- Avoids page breaks after headings, inside lists, and inside table cells
- Sets widow/orphan control to three lines of text

Give that a try for your starting point. If having any bad page breaks is unacceptable, then you can add the page-break-before, page-break-after, or page-break-inside rules to a special CSS class. Then, add that class manually to problematic table cells, paragraphs, or headings to fix things up.
Post Reply