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

Free Support Forum - aspose.com

Not able to put watermark after merging fields

Hi there, the problem is that this is working:


insertWatermarkText(dstDoc, "PREVIEW");
dstDoc.getMailMerge().execute(fields,vals);

dstDoc.save(dest_dir + filename) + ".pdf");

and this one is not producing watermark in the output pdf:

dstDoc.getMailMerge().execute(fields,vals);
insertWatermarkText(dstDoc, "PREVIEW ");

dstDoc.save(dest_dir + filename + ".pdf");

BUT if I save it as docx: dstDoc.save(dest_dir + filename + ".docx");
it's working fine, producing watermark in both cases.

insertWatermarkText procedure has been taken from documentation, dstDoc is DOCX document.

Aspose.Words 10.3., Java 1.4.2

Hi

Thanks for your request. You should call Document.UpdatePageLayout before saving document to PDF to resolve the problem. Please see the following code:

doc.updatePageLayout();

doc.save("C:\\Temp\\out.pdf");

The problem is caused because when you execute mail merge, Aspose.Words automatically updates fields in the document. Updating fields also runs updating page layout and the layout is cached. So changes made after updating page layout does not appear in the output PDF. So you should simply rebuild document layout to resolve the problem.

Best regards,

it's working, thank you very much