I have a Word document whose Top Margin was reduced to fit a lot of content on a single page.
When I use the following code to add a watermark, the TopMargin from the original document is lost and now the document spans two pages.
I know I can explictily set the TopMargin in code; the problem is that I have been unable to capture the original TopMargin value from the template (in code). A hard coded TopMargin value is not acceptable. In other words I need to preserve whatever TopMargin value was set in ANY Word document where I need to apply a watermark. Apose Words seems to reset the TopMargin to the default.
Here is the code for adding the watermark...
String imageFile = "D:/temp/AsposeTest/watermark.jpg";
String inFileName = "D:/temp/AsposeTest/DotWithSmallTopMargin.dot";
String outFileName = "D:/temp/AsposeTest/DocWithWatermark.doc";
Document doc = new Document(inFileName);
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert a floating picture.
Shape shape = builder.insertImage(imageFile);
// Position the image in the center of the page.
Attached are a test Word docment and watermark image.