opensagres / xdocreport

XDocReport means XML Document reporting. It's Java API to merge XML document created with MS Office (docx) or OpenOffice (odt), LibreOffice (odt) with a Java model to generate report and convert it if you need to another format (PDF, XHTML...).
https://github.com/opensagres/xdocreport
1.19k stars 369 forks source link

How to get into mapper.useTotalPageField() with the word document? #626

Open boonyachengdu opened 8 months ago

boonyachengdu commented 8 months ago

I found my word document with page footer not visible in the pdf. I wrote it with WPS and inserted the page footer information,but at the pdf footer without the page number content. Is that my word document has something problem? I never used oxxml to convert a word document to pdf, anybody can give some help? Thank you!

boonyachengdu commented 8 months ago

the most probable factors maybe the word document template

<pkg:part pkg:name="/word/footer1.xml" pkg:contentType="application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml">
    <pkg:xmlData>
      <w:ftr xmlns:wpc="http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" xmlns:w15="http://schemas.microsoft.com/office/word/2012/wordml" xmlns:wpg="http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" xmlns:wpi="http://schemas.microsoft.com/office/word/2010/wordprocessingInk" xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml" xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape" xmlns:wpsCustomData="http://www.wps.cn/officeDocument/2013/wpsCustomData" mc:Ignorable="w14 w15 wp14">
        <w:p>
          <w:pPr>
            <w:pStyle w:val="2"/>
            <w:tabs>
              <w:tab w:val="right" w:pos="8426"/>
            </w:tabs>
            <w:jc w:val="right"/>
            <w:rPr>
              <w:rFonts w:hint="default" w:eastAsia="宋体"/>
              <w:lang w:val="en-US" w:eastAsia="zh-CN"/>
            </w:rPr>
          </w:pPr>
          <w:r>
            <w:rPr>
              <w:sz w:val="18"/>
            </w:rPr>
            <mc:AlternateContent>
              <mc:Choice Requires="wps">
                <w:drawing>
                  <wp:anchor distT="0" distB="0" distL="114300" distR="114300" simplePos="0" relativeHeight="251659264" behindDoc="0" locked="0" layoutInCell="1" allowOverlap="1">
                    <wp:simplePos x="0" y="0"/>
                    <wp:positionH relativeFrom="margin">
                      <wp:align>center</wp:align>
                    </wp:positionH>
                    <wp:positionV relativeFrom="paragraph">
                      <wp:posOffset>0</wp:posOffset>
                    </wp:positionV>
                    <wp:extent cx="1828800" cy="1828800"/>
                    <wp:effectExtent l="0" t="0" r="0" b="0"/>
                    <wp:wrapNone/>
                    <wp:docPr id="3" name="文本框 3"/>
                    <wp:cNvGraphicFramePr/>
                    <a:graphic xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">
                      <a:graphicData uri="http://schemas.microsoft.com/office/word/2010/wordprocessingShape">
                        <wps:wsp>
                          <wps:cNvSpPr txBox="1"/>
                          <wps:spPr>
                            <a:xfrm>
                              <a:off x="0" y="0"/>
                              <a:ext cx="1828800" cy="1828800"/>
                            </a:xfrm>
                            <a:prstGeom prst="rect">
                              <a:avLst/>
                            </a:prstGeom>
                            <a:noFill/>
                            <a:ln w="6350">
                              <a:noFill/>
                            </a:ln>
                          </wps:spPr>
                          <wps:style>
                            <a:lnRef idx="0">
                              <a:schemeClr val="accent1"/>
                            </a:lnRef>
                            <a:fillRef idx="0">
                              <a:schemeClr val="accent1"/>
                            </a:fillRef>
                            <a:effectRef idx="0">
                              <a:schemeClr val="accent1"/>
                            </a:effectRef>
                            <a:fontRef idx="minor">
                              <a:schemeClr val="dk1"/>
                            </a:fontRef>
                          </wps:style>
                          <wps:txbx>
                            <w:txbxContent>
                              <w:p>
                                <w:pPr>
                                  <w:pStyle w:val="2"/>
                                </w:pPr>
                                <w:r>
                                  <w:t xml:space="preserve">第 </w:t>
                                </w:r>
                                <w:r>
                                  <w:fldChar w:fldCharType="begin"/>
                                </w:r>
                                <w:r>
                                  <w:instrText xml:space="preserve"> PAGE  \* MERGEFORMAT </w:instrText>
                                </w:r>
                                <w:r>
                                  <w:fldChar w:fldCharType="separate"/>
                                </w:r>
                                <w:r>
                                  <w:t>1</w:t>
                                </w:r>
                                <w:r>
                                  <w:fldChar w:fldCharType="end"/>
                                </w:r>
                                <w:r>
                                  <w:t xml:space="preserve"> 页 共 </w:t>
                                </w:r>
                                <w:r>
                                  <w:fldChar w:fldCharType="begin"/>
                                </w:r>
                                <w:r>
                                  <w:instrText xml:space="preserve"> NUMPAGES  \* MERGEFORMAT </w:instrText>
                                </w:r>
                                <w:r>
                                  <w:fldChar w:fldCharType="separate"/>
                                </w:r>
                                <w:r>
                                  <w:t>2</w:t>
                                </w:r>
                                <w:r>
                                  <w:fldChar w:fldCharType="end"/>
                                </w:r>
                                <w:r>
                                  <w:t xml:space="preserve"> 页</w:t>
                                </w:r>
                              </w:p>
                            </w:txbxContent>
                          </wps:txbx>
                          <wps:bodyPr rot="0" spcFirstLastPara="0" vertOverflow="overflow" horzOverflow="overflow" vert="horz" wrap="none" lIns="0" tIns="0" rIns="0" bIns="0" numCol="1" spcCol="0" rtlCol="0" fromWordArt="0" anchor="t" anchorCtr="0" forceAA="0" upright="0" compatLnSpc="1">
                            <a:spAutoFit/>
                          </wps:bodyPr>
                        </wps:wsp>
                      </a:graphicData>
                    </a:graphic>
                  </wp:anchor>
                </w:drawing>
              </mc:Choice>
              <mc:Fallback>
                <w:pict>
                  <v:shape id="_x0000_s1026" o:spid="_x0000_s1026" o:spt="202" type="#_x0000_t202" style="position:absolute;left:0pt;margin-top:0pt;height:144pt;width:144pt;mso-position-horizontal:center;mso-position-horizontal-relative:margin;mso-wrap-style:none;z-index:251659264;mso-width-relative:page;mso-height-relative:page;" filled="f" stroked="f" coordsize="21600,21600" o:gfxdata="UEsDBAoAAAAAAIdO4kAAAAAAAAAAAAAAAAAEAAAAZHJzL1BLAwQUAAAACACHTuJAs0lY7tAAAAAF&#10;AQAADwAAAGRycy9kb3ducmV2LnhtbE2PQUvDQBCF74L/YRmhN7tpKxJiNgVL06Ng48HjNjsm0d3Z&#10;sLtN4793FEEvwzze8OZ75XZ2VkwY4uBJwWqZgUBqvRmoU/DS1Lc5iJg0GW09oYJPjLCtrq9KXRh/&#10;oWecjqkTHEKx0Ar6lMZCytj26HRc+hGJvTcfnE4sQydN0BcOd1aus+xeOj0Qf+j1iLse24/j2SnY&#10;1U0TJozBvuKh3rw/Pd7hflZqcbPKHkAknNPfMXzjMzpUzHTyZzJRWAVcJP1M9tZ5zvL0u8iqlP/p&#10;qy9QSwMEFAAAAAgAh07iQOGA044yAgAAYQQAAA4AAABkcnMvZTJvRG9jLnhtbK1UzY7TMBC+I/EO&#10;lu80aStWVdV0VbYqQqrYlQri7DpOE8l/st0m5QHgDThx4c5z9Tn2c366aOGwBy7O2DP+xt83M1nc&#10;NkqSk3C+Mjqj41FKidDc5JU+ZPTzp82bGSU+MJ0zabTI6Fl4ert8/WpR27mYmNLIXDgCEO3ntc1o&#10;GYKdJ4nnpVDMj4wVGs7COMUCtu6Q5I7VQFcymaTpTVIbl1tnuPAep+vOSXtE9xJAUxQVF2vDj0ro&#10;0KE6IVkAJV9W1tNl+9qiEDzcF4UXgciMgmloVySBvY9rslyw+cExW1a8fwJ7yROecVKs0kh6hVqz&#10;wMjRVX9BqYo7400RRtyopCPSKgIW4/SZNruSWdFygdTeXkX3/w+Wfzw9OFLlGZ1SoplCwS8/vl9+&#10;/r78+kamUZ7a+jmidhZxoXlnGjTNcO5xGFk3hVPxCz4Efoh7voormkB4vDSbzGYpXBy+YQP85Om6&#10;dT68F0aRaGTUoXqtqOy09aELHUJiNm02lZRtBaU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9QSwECFAAU&#10;AAAACACHTuJAfublIPcAAADhAQAAEwAAAAAAAAABACAAAACbBAAAW0NvbnRlbnRfVHlwZXNdLnht&#10;bFBLAQIUAAoAAAAAAIdO4kAAAAAAAAAAAAAAAAAGAAAAAAAAAAAAEAAAAH0DAABfcmVscy9QSwEC&#10;FAAUAAAACACHTuJAihRmPNEAAACUAQAACwAAAAAAAAABACAAAAChAwAAX3JlbHMvLnJlbHNQSwEC&#10;FAAKAAAAAACHTuJAAAAAAAAAAAAAAAAABAAAAAAAAAAAABAAAAAAAAAAZHJzL1BLAQIUABQAAAAI&#10;AIdO4kCzSVju0AAAAAUBAAAPAAAAAAAAAAEAIAAAACIAAABkcnMvZG93bnJldi54bWxQSwECFAAU&#10;AAAACACHTuJA4YDTjjICAABhBAAADgAAAAAAAAABACAAAAAfAQAAZHJzL2Uyb0RvYy54bWxQSwUG&#10;AAAAAAYABgBZAQAAwwUAAAAA&#10;">
                    <v:fill on="f" focussize="0,0"/>
                    <v:stroke on="f" weight="0.5pt"/>
                    <v:imagedata o:title=""/>
                    <o:lock v:ext="edit" aspectratio="f"/>
                    <v:textbox inset="0mm,0mm,0mm,0mm" style="mso-fit-shape-to-text:t;">
                      <w:txbxContent>
                        <w:p>
                          <w:pPr>
                            <w:pStyle w:val="2"/>
                          </w:pPr>
                          <w:r>
                            <w:t xml:space="preserve">第 </w:t>
                          </w:r>
                          <w:r>
                            <w:fldChar w:fldCharType="begin"/>
                          </w:r>
                          <w:r>
                            <w:instrText xml:space="preserve"> PAGE  \* MERGEFORMAT </w:instrText>
                          </w:r>
                          <w:r>
                            <w:fldChar w:fldCharType="separate"/>
                          </w:r>
                          <w:r>
                            <w:t>1</w:t>
                          </w:r>
                          <w:r>
                            <w:fldChar w:fldCharType="end"/>
                          </w:r>
                          <w:r>
                            <w:t xml:space="preserve"> 页 共 </w:t>
                          </w:r>
                          <w:r>
                            <w:fldChar w:fldCharType="begin"/>
                          </w:r>
                          <w:r>
                            <w:instrText xml:space="preserve"> NUMPAGES  \* MERGEFORMAT </w:instrText>
                          </w:r>
                          <w:r>
                            <w:fldChar w:fldCharType="separate"/>
                          </w:r>
                          <w:r>
                            <w:t>2</w:t>
                          </w:r>
                          <w:r>
                            <w:fldChar w:fldCharType="end"/>
                          </w:r>
                          <w:r>
                            <w:t xml:space="preserve"> 页</w:t>
                          </w:r>
                        </w:p>
                      </w:txbxContent>
                    </v:textbox>
                  </v:shape>
                </w:pict>
              </mc:Fallback>
            </mc:AlternateContent>
          </w:r>
          <w:r>
            <w:rPr>
              <w:rFonts w:hint="eastAsia"/>
              <w:sz w:val="18"/>
              <w:lang w:val="en-US" w:eastAsia="zh-CN"/>
            </w:rPr>
            <w:tab/>
          </w:r>
          <w:r>
            <w:rPr>
              <w:rFonts w:hint="eastAsia"/>
              <w:sz w:val="18"/>
              <w:lang w:val="en-US" w:eastAsia="zh-CN"/>
            </w:rPr>
            <w:tab/>
          </w:r>
          <w:r>
            <w:rPr>
              <w:rFonts w:hint="eastAsia"/>
              <w:sz w:val="18"/>
              <w:lang w:val="en-US" w:eastAsia="zh-CN"/>
            </w:rPr>
            <w:t>合同编号:</w:t>
          </w:r>
          <w:r>
            <w:t>skdfdz20231019142503</w:t>
          </w:r>
        </w:p>
      </w:ftr>
    </pkg:xmlData>
  </pkg:part>
boonyachengdu commented 8 months ago

I installed Office and created a new word document, and the page Number is aviable. Office word template