I have an XML with newsletter articles. The relevant element nodes (title, intro, body,…) in the xml contain html code. In the datamapper this poses no problems:
The target in the designer is to have these three articles beneath each other. I have used a simple one-row-one-column dynamic table the do this:
The result comes close to the objective. The only problem is that each article is started on a new page, instead of right beneath the previous one.
I’ve played around with every combination of widows, orphans, page-break-before, page-break-after and page-break-inside I could think of, but to no avail. How can I force the first article to start on page 1 right beneath the light blue area and the next articles to start right below the previous one?
The package for this project is available here.
Thanks for any suggestions.
So, if you’re setting the Widow count on the Table to 2, it’s going to say: “I have 3 rows to display and this is going to overflow. I need to try to keep 2 on the first page and overflow the third”
The trouble is… your rows are too tall. All of that extra code you’re inserting via the datamapper is going into the same row. The total height of the first row ends up being too large to fit in the space allocated in your first page, so the whole thing is forced to overflow to the next page. This continues and your Widow settings are effectively ignored. There’s just not enough room for more than 1 row per page even on an otherwise blank page.
My suggestion would be to first ditch the detail table. You don’t need it. Instead, write a simple script to loop through Articles and insert your HTML directly in the flow of the document, one Article after the other. This gives exactly the results you’re after as your data is already broken up into small paragraphs. For example, if I remove your table and just insert the HTML on the page like below, it mostly works.
@keyword@
Tax
@title@ @intro@ @body@ @conclusion@
I say mostly because some of your sections include spans in them which, again, are preventing the page breaks from happening. Removing those allows it to flow quite nicely down the page.
Thanks Journeyman!
From your answer I gather there is no way to have a page break inside a row. Good to know.
You also say that spans prevent the page breaks from happening. Are there any more such elements that should be avoided? And since my html contains such spans I assume they’re there to do some css formatting. If I need to drop those spans, what can I replace them with to do the formatting, but without preventing the page breaks? Or can I add some css to the spans to allow them to do page breaks (e.g. page-break-inside or display)?
If you need them for formatting, I’d switch to something better suited to it like <article> tags. <span> is more for applying formatting to small sections of text in a larger body of text. Like this Bold here would be inside a span if you could see the HTML behind this post.
You might also consider using Spans to keep headers with their following paragraphs. For example, Here you see I’ve replaced your spans with articles, but the text Spot Checks ends up orphaned from it’ paragraph.
If I put the H4 and following P tag inside of a span, that’s going to keep them together like this:
Meanwhile you’ve still got the article tag wrapping the larger sections of text to give you something to apply global formatting to.
I’ve checked my data and there are only 2 spans in it which in both cased are only used for applying formatting to small sections of text in a larger body of text. So I don’t think my usage of span is problematic at all. The data in the package might have been based on an old version of the source xml and might not be very representative
Nevertheless, I really like your suggestion of encapsulating headers with their following paragraphs to keep them together.