Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is page break implemented correctly? #25

Closed
felipeochoa opened this issue Mar 12, 2017 · 5 comments
Closed

Is page break implemented correctly? #25

felipeochoa opened this issue Mar 12, 2017 · 5 comments

Comments

@felipeochoa
Copy link
Contributor

The implementation of paragraph.pageBreak() has it add a <w:br w:type="page"/> element to the w:pPr element of the paragraph. Looking at the spec, I could only find w:br under "17.3.3 Run Content", which is implemented as Run#break.

If my reading is correct, I think we should remove this method and add it to Run

@dolanmiu
Copy link
Owner

https://web.archive.org/web/20160820235211/http://officeopenxml.com/WPtextSpecialContent-break.php

I followed this documentation when implementing it

you can see that it has <w:br> with various options for type, including page

I'm using waybackmachine cos the original website is down (hence im porting it) 😂

@dolanmiu
Copy link
Owner

@dolanmiu
Copy link
Owner

I think you was thinking of the below. Paragraph and Run both have breaks! but they do different things.

https://github.com/dolanmiu/docx/wiki/Text#break

@jacwright
Copy link
Contributor

jacwright commented Sep 15, 2017

@dolanmiu you are correct that <w:br w:type="page"/> is the right way to create a paragraph break. However, docx currently puts that inside <w:pPr> which breaks it.

What it looks like now:

<w:p>
  <w:pPr>
    <w:r>
      <w:rPr />
      <w:br w:type="page" />
   </w:r>
  </w:pPr>
</w:p>

What it should look like:

<w:p>
    <w:r>
      <w:br w:type="page" />
   </w:r>
</w:p>

Update: at least, this is the difference between my docx generated file where the page break is unrecognized, and Word-created docx file where the page break is recognized. I can't seem to find anything else, and when I removed the <w:pPr> from my docx generated file by hand, the page break shows up in Word Online and Pages where I have been testing. This isn't the most scientific approach, apologies, but hopefully it helps.

@jacwright
Copy link
Contributor

This has been fixed in #41. We should be able to close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants