Page 1 of 1

Modifying default section-break in MS-Word

PostPosted: Wed Aug 14, 2013 10:51 pm
by nasirudeen2001
Hello,

I am using the below code to generate section-break (continuous) in my document report. But the last section-break gets modified into type "Next-Page" automatically. Even if I try to modify that manually, the last section-break always become "Next-Page".

Requesting help on this regard please.

Code: Select all
"<w:p xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" w:rsidR=\"00C638CD\" w:rsidRDefault=\"00C638CD\" w:rsidP=\"002979B6\">" +
               "<w:pPr>" +
                  "<w:sectPr w:rsidR=\"0008038F\" w:rsidSect=\"00C26E80\">" +
                     "<w:type w:val=\"continuous\"/>" +
                     "<w:pgSz w:w=\"11906\" w:h=\"16838\" w:code=\"1\"/>" +
                     "<w:pgMar w:gutter=\"0\" w:footer=\"567\" w:header=\"567\" w:left=\"1134\" w:bottom=\"1134\" w:right=\"567\" w:top=\"1134\"/>" +
                     "<w:cols w:space=\"567\"/>" +
                     "<w:docGrid w:linePitch=\"360\"/>" +
                  "</w:sectPr>" +
               "</w:pPr>" +
            "</w:p>";

Re: Modifying default section-break in MS-Word

PostPosted: Wed Aug 14, 2013 11:23 pm
by jason
What you see in Word is misleading/confusing.

Create a new docx in Word, then hit the enter key 10 times.

At the 5th paragraph marker, insert a section break of type oddpage.

Save the docx and inspect the results. You'll see:

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
<w:document >
  <w:body>
 
    <!-- paragraphs -->

    <w:p >
      <w:pPr>
        <w:sectPr >
          <w:pgSz w:w="12240" w:h="15840"/>
          <w:pgMar w:top="1440" w:right="1440" w:bottom="1440" w:left="1440" w:header="708" w:footer="708" w:gutter="0"/>
        </w:sectPr>
      </w:pPr>
    </w:p>
   
    <!-- paragraphs -->

    <w:sectPr>
      <w:type w:val="oddPage"/>
      <w:pgSz w:w="12240" w:h="15840"/>
      <w:pgMar w:top="1440" w:right="1440" w:bottom="1440" w:left="1440" w:header="708" w:footer="708" w:gutter="0"/>
    </w:sectPr>
  </w:body>
</w:document>
 
Parsed in 0.002 seconds, using GeSHi 1.0.8.4


Notice that the odd page sectPr is located at the end of the docx, not in the middle where you visually put it. This is because sectPr is at the end of the section to which it applies.

I think this is what you are seeing. If the problem is something different, then please attach a complete docx, and explain how it differs from what you want.

Re: Modifying default section-break in MS-Word

PostPosted: Thu Aug 15, 2013 12:03 am
by nasirudeen2001
Thanks for your response Jason.
I got your point. I may be looking at it in a different angle as I am totally new to docx4j.

Let me clear my issue. I am using docx4j to generate document report which fetches data from database dynamically.

Since there is a requirement to have a column break for a particular section,
I have added Column break for that and for rest "Section Break (w:val="Continuous").
There are some Pagebreaks also needed in document.

I have generated Section Break by unmarshalling the xml I had mentioned in previous post.
Now,
the report gets generated as expected which has data till Page-8. On this Page-8, the last Section-Break gets generated but it turns into Section-Break (w:val=Next-Page) whereas my code mentions it as (w:val="Continuous").

Generated document is attached for reference.[removed the document]

Thanks in advance.

Re: Modifying default section-break in MS-Word

PostPosted: Sun Aug 18, 2013 12:46 am
by nasirudeen2001
Finally it has got resolved.. I don't know why the last section break automatically got changed into "Next-Page" from "Continuous" and also I did not understand why it started working normally.. After struggling to resolve the issue for more than three days, the only change I did was adding a cover-page for the document with "page-break" in the end the cover-page...

Thanks Jason for your support :)