docx4j-ImportXHTML
docx4j-ImportXHTML copied to clipboard
added support page-break-before:always and page-break-after:always
Please review my changes.
Thanks, László
Not working in 8.0.1-SNAPSHOT.
A solution would be
private void addPageBreakBefore(BlockBox box) {
Map<String, CSSValue> cssMap = getCascadedProperties(box.getStyle());
CSSValue pageBreakAfter = cssMap.get("page-break-before");
if("always".equals(pageBreakAfter.getCssText())){
Br br = Context.getWmlObjectFactory().createBr();
br.setType(PAGE);
R r = Context.getWmlObjectFactory().createR();
r.getContent().add(br);
getListForRun().getContent().add(r);
}
}
private void addPageBreakAfter(BlockBox box) {
Map<String, CSSValue> cssMap = getCascadedProperties(box.getStyle());
CSSValue pageBreakAfter = cssMap.get("page-break-after");
if("always".equals(pageBreakAfter.getCssText())){
Br br = Context.getWmlObjectFactory().createBr();
br.setType(PAGE);
R r = Context.getWmlObjectFactory().createR();
r.getContent().add(br);
getListForRun().getContent().add(r);
}
}
Hello, The patch, using @hydra1983 code from the comment works very well. Any chance this PR can be merged? It's been 3 years now, so if another PR should be created instead of this one, let me know and i'll happily do the PR
Thanks, Fabien
@plutext Hello, here is the PR, ready to be merged in the 8.x branch: https://github.com/plutext/docx4j-ImportXHTML/pull/95 I believe it can also be cherry-picked in the 11.x branch
Thanks, Fabien