We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

The document is changed after adding watermark and QR code

Hello,


Sorry to bother you again.

The document is changed after our client add the watermark and QR code. Can you help them to solve it?

I have attached these two documents for your reference.

Thanks & Regards
Sara Yu
Shenzhen Chinasoft Information Technology Co., Ltd.
Rm.209, Shenzhen Academy of Aeroapace Technology Bldg., Kejinan 10th Rd.,South High-tech Zone,Nanshan Dist.,Shenzhen,China 518057
Skype: sara.yu1688
Tel: +86-755-26994896
Fax: +86-755-26996813
Mob:+86-18823209951
Email:yujq@chinasofttech.com
Web: www.sz168.com.cn

Hi Chinasoft,

Thanks for your inquiry. I have tested the scenario using the approach shared here and have not found the shared issue.

In case you are using an older version of Aspose.Words, I would suggest you please upgrade to the latest version (v14.7.0) from here and let us know how it goes on your side. If the problem still remains, please create a standalone/runnable simple Java application that demonstrates the code you used to generate your output document. I will investigate the issue on my side and provide you more information.

Hi,


For the problem, kindly check the attached pictures. The Format of document changes and justified on both side after they add the watermark.

Thanks & Regards
余佳婧 (Sara Yu)
Tel: +86-755-26994896
Mob:+86-18823209951

Hi Chinasoft,

Thanks for your inquiry. In case you are using an older version of Aspose.Words, I would suggest you please upgrade to the latest version (v14.7.0) from here and let us know how it goes on your side.

I have tested the scenario using latest version of Aspose.Words for Java 14.7.0 and have not found the shared issue. I have used the following code example to test this issue. Please check the attached output document.


private static void insertWatermarkImage(Document doc, String image) throws Exception

{

// Create a watermark shape. This will be a WordArt shape.

// You are free to try other shape types as watermarks.

Shape watermark = new Shape(doc, ShapeType.IMAGE);

watermark.getImageData().setImage(image);

// Place the watermark in the page center.

watermark.setRelativeHorizontalPosition(RelativeHorizontalPosition.PAGE);

watermark.setRelativeVerticalPosition(RelativeVerticalPosition.PAGE);

watermark.setWrapType(WrapType.NONE);

watermark.setVerticalAlignment(VerticalAlignment.CENTER);

watermark.setHorizontalAlignment(HorizontalAlignment.CENTER);

// Create a new paragraph and append the watermark to this paragraph.

Paragraph watermarkPara = new Paragraph(doc);

watermarkPara.appendChild(watermark);

// Insert the watermark into all headers of each document section.

for (Section sect : doc.getSections())

{

// There could be up to three different headers in each section, since we want

// the watermark to appear on all pages, insert into all headers.

insertWatermarkIntoHeader(watermarkPara, sect, HeaderFooterType.HEADER_PRIMARY);

insertWatermarkIntoHeader(watermarkPara, sect, HeaderFooterType.HEADER_FIRST);

insertWatermarkIntoHeader(watermarkPara, sect, HeaderFooterType.HEADER_EVEN);

}

}

<w:LatentStyles DefLockedState=“false” DefUnhideWhenUsed=“true”
DefSemiHidden=“true” DefQFormat=“false” DefPriority=“99”
LatentStyleCount=“267”>
<w:LsdException Locked=“false” Priority=“0” SemiHidden=“false”
UnhideWhenUsed=“false” QFormat=“true” Name=“Normal”/>
<w:LsdException Locked=“false” Priority=“9” SemiHidden=“false”
UnhideWhenUsed=“false” QFormat=“true” Name=“heading 1”/>
<w:LsdException Locked=“false” Priority=“9” QFormat=“true” Name=“heading 2”/>
<w:LsdException Locked=“false” Priority=“9” QFormat=“true” Name=“heading 3”/>
<w:LsdException Locked=“false” Priority=“9” QFormat=“true” Name=“heading 4”/>
<w:LsdException Locked=“false” Priority=“9” QFormat=“true” Name=“heading 5”/>
<w:LsdException Locked=“false” Priority=“9” QFormat=“true” Name=“heading 6”/>
<w:LsdException Locked=“false” Priority=“9” QFormat=“true” Name=“heading 7”/>
<w:LsdException Locked=“false” Priority=“9” QFormat=“true” Name=“heading 8”/>
<w:LsdException Locked=“false” Priority=“9” QFormat=“true” Name=“heading 9”/>
<w:LsdException Locked=“false” Priority=“39” Name=“toc 1”/>
<w:LsdException Locked=“false” Priority=“39” Name=“toc 2”/>
<w:LsdException Locked=“false” Priority=“39” Name=“toc 3”/>
<w:LsdException Locked=“false” Priority=“39” Name=“toc 4”/>
<w:LsdException Locked=“false” Priority=“39” Name=“toc 5”/>
<w:LsdException Locked=“false” Priority=“39” Name=“toc 6”/>
<w:LsdException Locked=“false” Priority=“39” Name=“toc 7”/>
<w:LsdException Locked=“false” Priority=“39” Name=“toc 8”/>
<w:LsdException Locked=“false” Priority=“39” Name=“toc 9”/>
<w:LsdException Locked=“false” Priority=“35” QFormat=“true” Name=“caption”/>
<w:LsdException Locked=“false” Priority=“10” SemiHidden=“false”
UnhideWhenUsed=“false” QFormat=“true” Name=“Title”/>
<w:LsdException Locked=“false” Priority=“1” Name=“Default Paragraph Font”/>
<w:LsdException Locked=“false” Priority=“11” SemiHidden=“false”
UnhideWhenUsed=“false” QFormat=“true” Name=“Subtitle”/>
<w:LsdException Locked=“false” Priority=“22” SemiHidden=“false”
UnhideWhenUsed=“false” QFormat=“true” Name=“Strong”/>
<w:LsdException Locked=“false” Priority=“20” SemiHidden=“false”
UnhideWhenUsed=“false” QFormat=“true” Name=“Emphasis”/>
<w:LsdException Locked=“false” Priority=“59” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Table Grid”/>
<w:LsdException Locked=“false” UnhideWhenUsed=“false” Name=“Placeholder Text”/>
<w:LsdException Locked=“false” Priority=“1” SemiHidden=“false”
UnhideWhenUsed=“false” QFormat=“true” Name=“No Spacing”/>
<w:LsdException Locked=“false” Priority=“60” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Light Shading”/>
<w:LsdException Locked=“false” Priority=“61” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Light List”/>
<w:LsdException Locked=“false” Priority=“62” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Light Grid”/>
<w:LsdException Locked=“false” Priority=“63” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Shading 1”/>
<w:LsdException Locked=“false” Priority=“64” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Shading 2”/>
<w:LsdException Locked=“false” Priority=“65” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium List 1”/>
<w:LsdException Locked=“false” Priority=“66” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium List 2”/>
<w:LsdException Locked=“false” Priority=“67” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Grid 1”/>
<w:LsdException Locked=“false” Priority=“68” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Grid 2”/>
<w:LsdException Locked=“false” Priority=“69” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Grid 3”/>
<w:LsdException Locked=“false” Priority=“70” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Dark List”/>
<w:LsdException Locked=“false” Priority=“71” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Colorful Shading”/>
<w:LsdException Locked=“false” Priority=“72” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Colorful List”/>
<w:LsdException Locked=“false” Priority=“73” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Colorful Grid”/>
<w:LsdException Locked=“false” Priority=“60” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Light Shading Accent 1”/>
<w:LsdException Locked=“false” Priority=“61” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Light List Accent 1”/>
<w:LsdException Locked=“false” Priority=“62” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Light Grid Accent 1”/>
<w:LsdException Locked=“false” Priority=“63” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Shading 1 Accent 1”/>
<w:LsdException Locked=“false” Priority=“64” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Shading 2 Accent 1”/>
<w:LsdException Locked=“false” Priority=“65” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium List 1 Accent 1”/>
<w:LsdException Locked=“false” UnhideWhenUsed=“false” Name=“Revision”/>
<w:LsdException Locked=“false” Priority=“34” SemiHidden=“false”
UnhideWhenUsed=“false” QFormat=“true” Name=“List Paragraph”/>
<w:LsdException Locked=“false” Priority=“29” SemiHidden=“false”
UnhideWhenUsed=“false” QFormat=“true” Name=“Quote”/>
<w:LsdException Locked=“false” Priority=“30” SemiHidden=“false”
UnhideWhenUsed=“false” QFormat=“true” Name=“Intense Quote”/>
<w:LsdException Locked=“false” Priority=“66” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium List 2 Accent 1”/>
<w:LsdException Locked=“false” Priority=“67” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Grid 1 Accent 1”/>
<w:LsdException Locked=“false” Priority=“68” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Grid 2 Accent 1”/>
<w:LsdException Locked=“false” Priority=“69” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Grid 3 Accent 1”/>
<w:LsdException Locked=“false” Priority=“70” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Dark List Accent 1”/>
<w:LsdException Locked=“false” Priority=“71” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Colorful Shading Accent 1”/>
<w:LsdException Locked=“false” Priority=“72” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Colorful List Accent 1”/>
<w:LsdException Locked=“false” Priority=“73” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Colorful Grid Accent 1”/>
<w:LsdException Locked=“false” Priority=“60” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Light Shading Accent 2”/>
<w:LsdException Locked=“false” Priority=“61” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Light List Accent 2”/>
<w:LsdException Locked=“false” Priority=“62” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Light Grid Accent 2”/>
<w:LsdException Locked=“false” Priority=“63” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Shading 1 Accent 2”/>
<w:LsdException Locked=“false” Priority=“64” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Shading 2 Accent 2”/>
<w:LsdException Locked=“false” Priority=“65” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium List 1 Accent 2”/>
<w:LsdException Locked=“false” Priority=“66” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium List 2 Accent 2”/>
<w:LsdException Locked=“false” Priority=“67” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Grid 1 Accent 2”/>
<w:LsdException Locked=“false” Priority=“68” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Grid 2 Accent 2”/>
<w:LsdException Locked=“false” Priority=“69” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Grid 3 Accent 2”/>
<w:LsdException Locked=“false” Priority=“70” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Dark List Accent 2”/>
<w:LsdException Locked=“false” Priority=“71” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Colorful Shading Accent 2”/>
<w:LsdException Locked=“false” Priority=“72” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Colorful List Accent 2”/>
<w:LsdException Locked=“false” Priority=“73” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Colorful Grid Accent 2”/>
<w:LsdException Locked=“false” Priority=“60” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Light Shading Accent 3”/>
<w:LsdException Locked=“false” Priority=“61” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Light List Accent 3”/>
<w:LsdException Locked=“false” Priority=“62” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Light Grid Accent 3”/>
<w:LsdException Locked=“false” Priority=“63” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Shading 1 Accent 3”/>
<w:LsdException Locked=“false” Priority=“64” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Shading 2 Accent 3”/>
<w:LsdException Locked=“false” Priority=“65” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium List 1 Accent 3”/>
<w:LsdException Locked=“false” Priority=“66” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium List 2 Accent 3”/>
<w:LsdException Locked=“false” Priority=“67” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Grid 1 Accent 3”/>
<w:LsdException Locked=“false” Priority=“68” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Grid 2 Accent 3”/>
<w:LsdException Locked=“false” Priority=“69” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Grid 3 Accent 3”/>
<w:LsdException Locked=“false” Priority=“70” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Dark List Accent 3”/>
<w:LsdException Locked=“false” Priority=“71” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Colorful Shading Accent 3”/>
<w:LsdException Locked=“false” Priority=“72” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Colorful List Accent 3”/>
<w:LsdException Locked=“false” Priority=“73” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Colorful Grid Accent 3”/>
<w:LsdException Locked=“false” Priority=“60” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Light Shading Accent 4”/>
<w:LsdException Locked=“false” Priority=“61” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Light List Accent 4”/>
<w:LsdException Locked=“false” Priority=“62” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Light Grid Accent 4”/>
<w:LsdException Locked=“false” Priority=“63” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Shading 1 Accent 4”/>
<w:LsdException Locked=“false” Priority=“64” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Shading 2 Accent 4”/>
<w:LsdException Locked=“false” Priority=“65” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium List 1 Accent 4”/>
<w:LsdException Locked=“false” Priority=“66” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium List 2 Accent 4”/>
<w:LsdException Locked=“false” Priority=“67” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Grid 1 Accent 4”/>
<w:LsdException Locked=“false” Priority=“68” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Grid 2 Accent 4”/>
<w:LsdException Locked=“false” Priority=“69” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Grid 3 Accent 4”/>
<w:LsdException Locked=“false” Priority=“70” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Dark List Accent 4”/>
<w:LsdException Locked=“false” Priority=“71” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Colorful Shading Accent 4”/>
<w:LsdException Locked=“false” Priority=“72” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Colorful List Accent 4”/>
<w:LsdException Locked=“false” Priority=“73” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Colorful Grid Accent 4”/>
<w:LsdException Locked=“false” Priority=“60” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Light Shading Accent 5”/>
<w:LsdException Locked=“false” Priority=“61” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Light List Accent 5”/>
<w:LsdException Locked=“false” Priority=“62” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Light Grid Accent 5”/>
<w:LsdException Locked=“false” Priority=“63” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Shading 1 Accent 5”/>
<w:LsdException Locked=“false” Priority=“64” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Shading 2 Accent 5”/>
<w:LsdException Locked=“false” Priority=“65” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium List 1 Accent 5”/>
<w:LsdException Locked=“false” Priority=“66” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium List 2 Accent 5”/>
<w:LsdException Locked=“false” Priority=“67” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Grid 1 Accent 5”/>
<w:LsdException Locked=“false” Priority=“68” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Grid 2 Accent 5”/>
<w:LsdException Locked=“false” Priority=“69” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Grid 3 Accent 5”/>
<w:LsdException Locked=“false” Priority=“70” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Dark List Accent 5”/>
<w:LsdException Locked=“false” Priority=“71” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Colorful Shading Accent 5”/>
<w:LsdException Locked=“false” Priority=“72” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Colorful List Accent 5”/>
<w:LsdException Locked=“false” Priority=“73” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Colorful Grid Accent 5”/>
<w:LsdException Locked=“false” Priority=“60” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Light Shading Accent 6”/>
<w:LsdException Locked=“false” Priority=“61” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Light List Accent 6”/>
<w:LsdException Locked=“false” Priority=“62” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Light Grid Accent 6”/>
<w:LsdException Locked=“false” Priority=“63” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Shading 1 Accent 6”/>
<w:LsdException Locked=“false” Priority=“64” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Shading 2 Accent 6”/>
<w:LsdException Locked=“false” Priority=“65” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium List 1 Accent 6”/>
<w:LsdException Locked=“false” Priority=“66” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium List 2 Accent 6”/>
<w:LsdException Locked=“false” Priority=“67” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Grid 1 Accent 6”/>
<w:LsdException Locked=“false” Priority=“68” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Grid 2 Accent 6”/>
<w:LsdException Locked=“false” Priority=“69” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Medium Grid 3 Accent 6”/>
<w:LsdException Locked=“false” Priority=“70” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Dark List Accent 6”/>
<w:LsdException Locked=“false” Priority=“71” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Colorful Shading Accent 6”/>
<w:LsdException Locked=“false” Priority=“72” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Colorful List Accent 6”/>
<w:LsdException Locked=“false” Priority=“73” SemiHidden=“false”
UnhideWhenUsed=“false” Name=“Colorful Grid Accent 6”/>
<w:LsdException Locked=“false” Priority=“19” SemiHidden=“false”
UnhideWhenUsed=“false” QFormat=“true” Name=“Subtle Emphasis”/>
<w:LsdException Locked=“false” Priority=“21” SemiHidden=“false”
UnhideWhenUsed=“false” QFormat=“true” Name=“Intense Emphasis”/>
<w:LsdException Locked=“false” Priority=“31” SemiHidden=“false”
UnhideWhenUsed=“false” QFormat=“true” Name=“Subtle Reference”/>
<w:LsdException Locked=“false” Priority=“32” SemiHidden=“false”
UnhideWhenUsed=“false” QFormat=“true” Name=“Intense Reference”/>
<w:LsdException Locked=“false” Priority=“33” SemiHidden=“false”
UnhideWhenUsed=“false” QFormat=“true” Name=“Book Title”/>
<w:LsdException Locked=“false” Priority=“37” Name=“Bibliography”/>
<w:LsdException Locked=“false” Priority=“39” QFormat=“true” Name=“TOC Heading”/>
</w:LatentStyles>
<![endif]–><!–[if gte mso 10]>

/* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin-top:0in; mso-para-margin-right:0in; mso-para-margin-bottom:10.0pt; mso-para-margin-left:0in; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin;}

<![endif]–>

Hi,


Thanks.This problem has been solved after they updated to the the newest version.aspose-words-14.7.0-jdk16.jar

But a new problem came out. It was unable to add the watermark into the picture (attached document).It works fine in the old version.

Best Regards
Sara




Hi Sara,

Thanks for your inquiry. It would be great if you please share following detail for investigation purposes.


  • Please attach your input Word document.
  • Please

    create a standalone/runnable simple Java application that demonstrates the code (Aspose.Words code) you used to generate
    your output document

  • Please attach the output Word file that shows the undesired behavior.
  • Please
    attach your target Word document showing the desired behavior. You can
    use Microsoft Word to create your target Word document. I will
    investigate as to how you are expecting your final document be generated
    like.

Unfortunately,
it is difficult to say what the problem is without the Document(s) and
simplified application. We need your Document(s) and simple project to
reproduce the problem. As soon as you get these pieces of information to
us we’ll start our investigation into your issue.

Hi ,


Here the code:

private void xxxxxx(DecorateContext context, byte[] qrCodeBytes, byte[] wmBytes) throws Exception {<o:p></o:p>

Document doc = context.getContent(Document.class);<o:p></o:p>

<o:p></o:p>

Map<String, Paragraph> wmGraphMap = new HashMap<>();<o:p></o:p>

Map<String, Paragraph> qrCodeGraphMap = new HashMap<>();<o:p></o:p>

HeaderFooter headerFooter = null;<o:p></o:p>

// Insert the watermark into all headers of each document section.<o:p></o:p>

for (Section sect : doc.getSections()) {<o:p></o:p>

PageSetup ps = sect.getPageSetup();<o:p></o:p>

String key = ps.getPageWidth() + “_” + ps.getPageHeight();<o:p></o:p>

if (wmBytes != null) {<o:p></o:p>

Paragraph watermarkPara = wmGraphMap.get(key);<o:p></o:p>

if (watermarkPara == null) {<o:p></o:p>

watermarkPara = new Paragraph(doc);<o:p></o:p>

watermarkPara.appendChild(generateShape(context, doc, ps, wmBytes, ImageType.WATERMARK));<o:p></o:p>

wmGraphMap.put(key, watermarkPara);<o:p></o:p>

}<o:p></o:p>

// There could be up to three different headers in each section,<o:p></o:p>

// since we want<o:p></o:p>

// the watermark to appear on all pages, insert into all headers.<o:p></o:p>

insertWatermarkIntoHeader(watermarkPara, sect, headerFooter, HeaderFooterType.HEADER_PRIMARY);<o:p></o:p>

insertWatermarkIntoHeader(watermarkPara, sect, headerFooter, HeaderFooterType.HEADER_FIRST);<o:p></o:p>

insertWatermarkIntoHeader(watermarkPara, sect, headerFooter, HeaderFooterType.HEADER_EVEN);<o:p></o:p>

} <o:p></o:p>

}<o:p></o:p>

doc.updatePageLayout();<o:p></o:p>

}<o:p></o:p>

private void yyyyy(Paragraph watermarkPara, Section sect, HeaderFooter headerFooter, int headerType) throws Exception {<o:p></o:p>

HeaderFooter header = sect.getHeadersFooters().getByHeaderFooterType(headerType);<o:p></o:p>

if (header == null) {<o:p></o:p>

if (headerFooter == null) {<o:p></o:p>

header = new HeaderFooter(sect.getDocument(), headerType);<o:p></o:p>

sect.getHeadersFooters().add(header);<o:p></o:p>

} else {<o:p></o:p>

header = (HeaderFooter) headerFooter.deepClone(true);<o:p></o:p>

}<o:p></o:p>

} else {<o:p></o:p>

headerFooter = (HeaderFooter) header.deepClone(true);<o:p></o:p>

}<o:p></o:p>

Paragraph gg = header.getLastParagraph();<o:p></o:p>

if (gg != null) {<o:p></o:p>

Paragraph newnode = (Paragraph) watermarkPara.deepClone(true);<o:p></o:p>

int count = newnode.getCount();<o:p></o:p>

if (count >= 1) {<o:p></o:p>

gg.appendChild(newnode.getFirstChild());<o:p></o:p>

}<o:p></o:p>

if (count >= 2) {<o:p></o:p>

gg.appendChild(newnode.getLastChild());<o:p></o:p>

}<o:p></o:p>

} else {<o:p></o:p>

header.appendChild(watermarkPara.deepClone(true));<o:p></o:p>

}<o:p></o:p>

}



And when they add the watermark in the document, it said:

log4j:WARN No appenders could be found for logger (webLogger).<o:p></o:p>

log4j:WARN Please initialize the log4j system properly.<o:p></o:p>

log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.<o:p></o:p>

com.huawei.it.edoc.decorate.DecorateException: process failed<o:p></o:p>

at com.huawei.it.edoc.decorate.WordDecorator.process(WordDecorator.java:247)<o:p></o:p>

at com.huawei.it.edoc.decorate.AbstractDecorator.decorate(AbstractDecorator.java:78)<o:p></o:p>

at com.huawei.it.edoc.decorate.WordDecoratorTest.test(WordDecoratorTest.java:64)<o:p></o:p>

at com.huawei.it.edoc.decorate.WordDecoratorTest.main(WordDecoratorTest.java:31)<o:p></o:p>

Caused by: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.IllegalArgumentException: Width (0) and height (0) cannot be <= 0<o:p></o:p>

at com.aspose.words.zzZQK.zzZ(Unknown Source)<o:p></o:p>

at com.aspose.words.zzZQK.zzY(Unknown Source)<o:p></o:p>

at com.aspose.words.zzZ4A.zzZiC(Unknown Source)<o:p></o:p>

at com.aspose.words.zzZ49.getWidth(Unknown Source)<o:p></o:p>

at com.aspose.words.zzZ4B.zzu0(Unknown Source)<o:p></o:p>

at com.aspose.words.zzZ54.getWidth(Unknown Source)<o:p></o:p>

at com.aspose.words.zzZPV.zzZLr(Unknown Source)<o:p></o:p>

at com.aspose.words.zzZPV.zzT(Unknown Source)<o:p></o:p>

at com.aspose.words.zzZQ2.zzS(Unknown Source)<o:p></o:p>

at com.aspose.words.zzZQ1.zzQ(Unknown Source)<o:p></o:p>

at com.aspose.words.zzZQ1.zzX(Unknown Source)<o:p></o:p>

at com.aspose.words.zzWN.zzZ(Unknown Source)<o:p></o:p>

at com.aspose.words.zzZ5I.zzZkN(Unknown Source)<o:p></o:p>

at com.aspose.words.zzZ5I.zzZ(Unknown Source)<o:p></o:p>

at com.aspose.words.zzXJ.zzvn(Unknown Source)<o:p></o:p>

at com.aspose.words.zzXJ.zzX(Unknown Source)<o:p></o:p>

at com.aspose.words.zzZE8.zzJ(Unknown Source)<o:p></o:p>

at com.aspose.words.zzZE8.zzS(Unknown Source)<o:p></o:p>

at com.aspose.words.zzZDQ.zzy(Unknown Source)<o:p></o:p>

at com.aspose.words.zzZ3Q.zzSy(Unknown Source)<o:p></o:p>

at com.aspose.words.zzDD.zzXY(Unknown Source)<o:p></o:p>

at com.aspose.words.zzDE.zz9r(Unknown Source)<o:p></o:p>

at com.aspose.words.zzZR3.zzZ(Unknown Source)<o:p></o:p>

at com.aspose.words.Document.updatePageLayout(Unknown Source)<o:p></o:p>

at com.huawei.it.edoc.decorate.WordDecorator.insertTextWatermark(WordDecorator.java:172)<o:p></o:p>

at com.huawei.it.edoc.decorate.WordDecorator.process(WordDecorator.java:243)<o:p></o:p>

… 3 more<o:p></o:p>

Caused by: java.lang.RuntimeException: java.lang.IllegalArgumentException: Width (0) and height (0) cannot be <= 0<o:p></o:p>

at com.aspose.words.zzE6.zzZ(Unknown Source)<o:p></o:p>

at com.aspose.words.zzG1.zzZ(Unknown Source)<o:p></o:p>

at com.aspose.words.zzG1.zzZ(Unknown Source)<o:p></o:p>

at com.aspose.words.zzG1.zzY(Unknown Source)<o:p></o:p>

at com.aspose.words.zzZQK.zzX(Unknown Source)<o:p></o:p>

at com.aspose.words.zzZQK.zzZ(Unknown Source)<o:p></o:p>

… 28 more<o:p></o:p>

Caused by: java.lang.IllegalArgumentException: Width (0) and height (0) cannot be <= 0<o:p></o:p>

at java.awt.image.DirectColorModel.createCompatibleWritableRaster(DirectColorModel.java:1016)<o:p></o:p>

at java.awt.image.BufferedImage.(BufferedImage.java:340)<o:p></o:p>

at asposewobfuscated.zzOY.(Unknown Source)<o:p></o:p>

at asposewobfuscated.zzOY.(Unknown Source)<o:p></o:p>

at asposewobfuscated.zzOY.(Unknown Source)<o:p></o:p>

at com.aspose.words.zzF6.zzY(Unknown Source)<o:p></o:p>

at com.aspose.words.zzF6.zzY(Unknown Source)<o:p></o:p>

at com.aspose.words.zzF6.zzY(Unknown Source)<o:p></o:p>

at com.aspose.words.zzF6.zzZ(Unknown Source)<o:p></o:p>

at com.aspose.words.zzFK.zzZ(Unknown Source)<o:p></o:p>

at com.aspose.words.zzFK.zzE(Unknown Source)<o:p></o:p>

at com.aspose.words.zzFT.zzY(Unknown Source)<o:p></o:p>

at com.aspose.words.zzFT.zzB(Unknown Source)<o:p></o:p>

at com.aspose.words.zzFT.zzY(Unknown Source)<o:p></o:p>

at com.aspose.words.zzFT.zzZ(Unknown Source)<o:p></o:p>

at com.aspose.words.zzFT.zzZ(Unknown Source)<o:p></o:p>

at com.aspose.words.zzH4.zzZ(Unknown Source)<o:p></o:p>

at com.aspose.words.zzE6.zzZ(Unknown Source)<o:p></o:p>

… 33 more<o:p></o:p>

The version they used is aspose-words-14.7.0

And I also added the input document.


Any comments pls let me know.

Sara

Hi Sara,

Thanks for sharing the detail. I am afraid I can not find the code for generateShape method. Please share the complete code which you are using to generate output document.

Please
attach your target Word document showing the desired behavior. You can
use Microsoft Word to create your target Word document. I will
investigate as to how you are expecting your final document be generated
like.