Watermark size and orientation changes after Word to PDF conversion

I am using .Net PDF to convert word doc created by Aspose.word. The test watermark looks fine in the word doc (just like the one created inside Word doc). But after the conversion, the test watermark is converted to a large grey box across the edge of the page. I couldn't send you the work doc I used to do test. But you can do a test by create a doc with Word doc and add a test watermark to it, then run word to PDF conversion, you will find that the watermark is shrunken and orientation is also changed. How to reserve the watermark of the original word doc after PDF conversion?

Hi,

I justed tested a word document with an image watermark and got a correct output file. Please provide your testing doc.

Hi,

Thanks you for considering Aspose.

I have tried the following code and was unable to reproduce the error that you report. Please have a look at the code and tell me if you are trying to do something different. Also what type of image are you using for watermark.

Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);

System.Drawing.Image image = System.Drawing.Image.FromFile("test.png");

// Insert a floating picture.

Aspose.Words.Drawing.Shape shape = builder.InsertImage(image);

shape.WrapType = Aspose.Words.Drawing.WrapType.None;

shape.BehindText = true;

shape.RelativeHorizontalPosition = Aspose.Words.Drawing.RelativeHorizontalPosition.Page;

shape.RelativeVerticalPosition = Aspose.Words.Drawing.RelativeVerticalPosition.Page;

// Calculate image left and top position so it appears in the centre of the page.

shape.Left = (builder.PageSetup.PageWidth - shape.Width) / 2;

shape.Top = (builder.PageSetup.PageHeight - shape.Height) / 2;

// Save the doc in a xml fille that can be handled by Aspose.Pdf.

doc.Save("test.xml", SaveFormat.AsposePdf);

// New a pdf object.

Aspose.Pdf.Pdf pdf = new Aspose.Pdf.Pdf();

// Bind content from the named xml file.

pdf.BindXML("test.xml", null);

// Save the result

pdf.Save("test.pdf");

Thanks.

Adeel Ahmad
Support Developer
Aspose Changsha Team
http://www.aspose.com/Wiki/default. aspx/Aspose.Corporate/ContactChangsha.html

We could not use image file here since the content of test watermarker may change based on the user input. Here are two file I ran test. I am expecting the same size and orientation<o:p></o:p> of the pdf output. But the test.pdf lost both of them.

Post the word doc again.

The diagonal and semitransparent text watermark is not supported well in Aspose.Pdf. We will add support for this in the future version.

But we need the similiar look and feel of watermark in the converted PDF file. Could you provide someway to workaround this problem?

Here is a workaround but it is still not perfect:

Remove the watermark in the Word document and add it after binding xml:

pdf.BindXML(@"D:\test\testword\input.xml",null);

//add watermark here
Aspose.Pdf.Section sec1 = pdf.Sections[0];
Aspose.Pdf.HeaderFooter header = sec1.OddHeader;

Text t1 = new Text("test purpose");
t1.Segments[0].TextInfo.FontSize = 70;
t1.Segments[0].TextInfo.RenderingMode = RenderingMode.StrokeText;
t1.PositioningType = PositioningType.PageRelative;
t1.Left = 200;
t1.Top = 500;
t1.RotatingAngle = 35;
header.Paragraphs.Add(t1);