Word to PDF: Add Watermark issue

Hi,

I am using the ASPOSE PDF component to convert some word documents to their PDF equivalents. In the MS Word document there already exists a watermark image and I need to put it the same way in the exported PDF. I have few queries on this:

  • If the Word document has a watermark image already existing, while exporting the document to PDF will this image also get imported automatically to PDF?
  • If I try to add a new watermark from PDF will this overwrite the existing Word watermark image?
  • Can I align the watermark image diagonally across the page?
I am not able to test the above points as I am using an evaluation version of the ASPOSE PDF component and as such it doesn’t allow me to add/edit watermarks. It just shows the “Aspose.Pdf” image as the watermark every time on each and every page. Also my existing MS Word watermark is not visible when I view the converted PDF. Please assist.

I used the following code as posted in your documentation:
//-----------------------------------------------------------------------
//image watermark
//-----------------------------------------------------------------------
Aspose.Pdf.Image image1 = new Aspose.Pdf.Image();
image1.ImageInfo.File = @“D:\Templates\Images\Watermark.JPG”;
image1.ImageInfo.ImageFileType = ImageFileType.Jpeg;
image1.ImageScale = 1.0f;
FloatingBox watermark1 = new FloatingBox(180, 400);
watermark1.BoxHorizontalPositioning = BoxHorizontalPositioningType.Page;
watermark1.BoxHorizontalAlignment = BoxHorizontalAlignmentType.Center;
watermark1.BoxVerticalPositioning = BoxVerticalPositioningType.Page;
watermark1.BoxVerticalAlignment = BoxVerticalAlignmentType.Center;
watermark1.Paragraphs.Add(image1);
//------------------------------------------------------------------------

Regards,
Vaibhav Modak

Hello Vaibhav,

Thanks for considering Aspose.

If the Word document has a watermark image already existing, while exporting the document to PDF will this image also get imported automatically to PDF?

If you are using Aspose.Pdf & Aspose.Words to convert a word file containing Watermark, then the resultant PDF would contain watermark along with other contents of the document.

If I try to add a new watermark from PDF will this overwrite the existing Word watermark image?

Aspose.Pdf is a component which is used to generate PDF documents from scratch. The code snippet that you have shared is used when you are trying to generate a PDF document using our API. In case you need to add a watermark during Word to Pdf conversion, please try using the following code snippet. You can set the position of watermark by setting appropriate values for FloatingBox object.

[C#]

Document doc = new Document(@"D:\pdftest\Word_to_Pdf.doc");
doc.Save(@"D:\pdftest\Word_to_Pdf.xml", SaveFormat.AsposePdf);

// New a pdf object
Aspose.Pdf.Pdf pdf11 = new Aspose.Pdf.Pdf();
// Bind content from the named xml file.
pdf11.BindXML(@"D:\pdftest\Word_to_Pdf.xml", null);
pdf11.IsTruetypeFontMapCached = true;
pdf11.TruetypeFontMapPath = @"D:\pdftest";
// use this property to assign proper font to Segment paragraph according to its contents
pdf11.IsAutoFontAdjusted = true;

Aspose.Pdf.Image image1 = new Aspose.Pdf.Image();
image1.ImageInfo.File = @"D:\pdftest\Aspose.jpg";
image1.ImageInfo.ImageFileType = ImageFileType.Jpeg;
image1.ImageScale = 1.0f;

FloatingBox watermark1 = new FloatingBox(180, 400);
watermark1.BoxHorizontalPositioning = BoxHorizontalPositioningType.Page;
watermark1.BoxHorizontalAlignment = BoxHorizontalAlignmentType.Center;
watermark1.BoxVerticalPositioning = BoxVerticalPositioningType.Page;
watermark1.BoxVerticalAlignment = BoxVerticalAlignmentType.Center;
watermark1.Paragraphs.Add(image1);
pdf11.Watermarks.Add(watermark1);

pdf11.Save(@"D:\pdftest\Word_to_Pdf_new.pdf");

Can I align the watermark image diagonally across the page?

As I've already mentioned you can control the positioning of the watermark by setting appropriate position for the FloatinBox object.

In order to test the product, you can also request a 30 days Temporary License. Please visit the following link for information on how Get a temporary license

I would also recommend you to visit Customizing Watermark

In case you still face any issue, please feel free to contact.