docx4j-ImportXHTML icon indicating copy to clipboard operation
docx4j-ImportXHTML copied to clipboard

added support page-break-before:always and page-break-after:always

Open laszlocseko opened this issue 7 years ago • 3 comments

Please review my changes.

Thanks, László

laszlocseko avatar Apr 21 '17 09:04 laszlocseko

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);
        }
    }

hydra1983 avatar May 30 '20 20:05 hydra1983

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

fnicollet avatar May 13 '23 14:05 fnicollet

@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

fnicollet avatar May 15 '23 11:05 fnicollet