You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by GitBox <gi...@apache.org> on 2022/03/30 03:46:52 UTC

[GitHub] [poi] quimperval commented on pull request #310: Allow sections to have distinct headers and footers

quimperval commented on pull request #310:
URL: https://github.com/apache/poi/pull/310#issuecomment-1082590734


   Hello @carmceart 
   
   I've created a branch, from the commit just before the PR 310, and created a simple document with different sections. 
   
   https://github.com/quimperval/poi/tree/simple-multi-section-document
   
   You can find it in the path 
   
   poi-examples/src/main/java/org/apache/poi/examples/xwpf/usermodel/SimpleMultiSectionDocument.java
   
   As you can see in the example, for each paragraph  was added a section properties object, to store data related to section complementary information, in the case of the example to show the behavior, for odd pages the orientation was set as portrait and for even pages was set as landscape. 
   
   The object sectPr stores the date related to page size, and orientation. 
   
   I've opened the generated docx file in libre office and it is showing three pages, one for each section. 
   ![libreOfficeMultiSectionDocument](https://user-images.githubusercontent.com/37852154/160746487-c5ccee32-ad8f-41bd-bb73-d61acba3ddfe.png)
   
   And I've opened the file with microsoft office online, it is adding an extra page at the end of the three sections.
   ![MsOfficeMultiSectionDocument](https://user-images.githubusercontent.com/37852154/160746558-229c1e4d-c665-4b2b-9720-2e0840d8b4c3.png)
   
   I guess Ms Office is adding an extra page because the sectPr object, related to the main body of the document, was not set. So, word adds the empty page. 
   
   I guess it could be possible to get the last sectPr of a paragraph and assign it to the main body, and then replace the section properties object of the paragraph, where we got the sectPr, with a null value. I guess in this case word would be showing the last paragraph without sectPr with the main body sectPr object.
   
   This happens regardless of PR 310.
   
   I could try to create a way to do what I described above and submit as a PR, to prevent an extra page added by word. I need sometime to work on it.
   
   FYI @pjfanning 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org