DITA to PDF Using HTML5 and CSS: Forced Page Breaks

patjporter
Posts: 13
Joined: Sat May 22, 2021 6:04 pm

DITA to PDF Using HTML5 and CSS: Forced Page Breaks

Post by patjporter » Mon Oct 11, 2021 8:14 pm

Hello, thank you for all the great answers on modifying my CSS files.

I have a few questions about page breaks.

Is there a way to force "keep with next". For example if I have two paragraphs I want to keep together across a page break?

Same question for tables. If I want the table to start at the top of a new page?

Finally, how do I keep a caption and a table or figure together? I have an example where the caption is on one page but the figure breaks to the next page.

Thank you!!
Pat

Dan
Posts: 492
Joined: Mon Feb 03, 2003 10:56 am

Re: DITA to PDF Using HTML5 and CSS: Forced Page Breaks

Post by Dan » Tue Oct 12, 2021 9:01 am

Hello Pat,

Yes, you can fine tune the page breaking as explained here:
https://www.oxygenxml.com/doc/versions/ ... aid-title4
If you want to force a page break for a specific topic, mark the topic (or any other element you need to control page breaking for) with an @outputclass attribute set to one of these values:

page-break-before
Use this for a page break before the marked element.
page-break-after
Use this for a page break after the marked element.
page-break-avoid
Use this to avoid page breaks inside the marked element.

For example, to force a page break before a certain topic, use:

<topic outputclass="page-break-before" ... >
So I would use

Code: Select all

<table outputclass="page-break-before" ...>
on the tables that need to start on a new page.

If you want to avoid page breaks in all figures, you should avoid setting an outputclass attribute, instead you should an add to your CSS customization:

Code: Select all

*[class~="topic/fig"] {
  page-break-inside:avoid;
}
Many regards,
Dan

Post Reply