This repository has been archived by the owner. It is now read-only.

Process page breaks #246

Closed
wants to merge 2 commits into
base: vNext
from

Conversation

Projects
None yet
3 participants
@NicoJuicy
Copy link

NicoJuicy commented Sep 6, 2018

Page breaks are shown like

<p:r><docx properties like font, .../><w:br type="page"/></p:r>

When converting this to HTML, this is replaced by in the function:

 // Transform w:br to h:br.
 if (element.Name == W.br || element.Name == W.cr)
  {
       return ProcessBreak(element);
  }

Which causes the page break to not appear.

I have changed this so it returns a div style="page-break-before:always;" in the following function.

private static object ProcessPageBreak(XElement element)
    {
        XElement div = new XElement(Xhtml.div);
        div.SetAttributeValue(NoNamespace.style, "page-break-before:always;");
        XElement span = null;

        return new object[]
        {
            div,
            new XEntity("#x200e"),
            span
     };
    }

Which causes a correct page break.

PS. The page break (docx) is detected in a child element. So i have to set the page break ( html) in it's parent. I detect it with the following function:

 private static bool HasAPageBreak(XElement element)
    {
        return element.Descendants().Any(dl => dl.Name == W.br && dl.Attribute(W.type).Value == "page");
    }
Nico Sap Nico Sap
@msftclas

This comment has been minimized.

Copy link

msftclas commented Sep 6, 2018

CLA assistant check
All CLA requirements met.

Fix after testing
Some tests seem to fail ( null reference) - fixed now
@NicoJuicy

This comment has been minimized.

Copy link
Author

NicoJuicy commented Sep 7, 2018

I added an issue here: #248

@tomjebo

This comment has been minimized.

Copy link
Collaborator

tomjebo commented Feb 2, 2019

Closing all PRs as this repo is being archived and will no longer be maintained by Microsoft. The project is licensed for continued use and development by forking to your own repo.

@tomjebo tomjebo closed this Feb 2, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.