Free Support Forum - aspose.com

Watermark washout property

Hi, we are using c-sharp to insert watermarks into templates. Some watermarks do not show up on the templates and upon investigation I have found that the 'Washout' property has been checked.

I would like to know if there is a way to set the property to unchecked using c-sharp?

Thanks,

Aaron

Hi Aaron,


Thanks for your inquiry. We will consider adding appropriate properties in our API to be able to enable/disable Sepia and Washout color modes for images. I have logged a new feature request in our bug tracking system. The issue ID is WORDSNET-7103. Your request has been linked to this feature and you will be notified as soon as it is available. Sorry for the inconvenience.

Best Regards,

Hi, I would like to know if there is a work-a-round for our current issue?

Hi Aaron,

Thanks for your inquiry. Could you please attach your Word document and code here for testing? I will investigate the issue on my side and provide you more information.

Best Regards,

Hi,

I've attached a vs2005 solution with examples of "working and not working" watermarks.

Hi Aaron,


Thanks for your inquiry. There are many DrawingML nodes inside different headers/footers in your watermark documents (the documents you’re using as watermark for example ‘NotWorking.docx’). I would suggest you first convert this whole document to an image format e.g. PNG and then generate a clean intermediate document by placing this PNG at the first header. You can then finally copy the contents of the headers/footers from this document into your template document as follows:

Document doc = new
Document(@“C:\Temp\notworking.doc”);

//Save document to an Image format

MemoryStream imgStream = new MemoryStream();

doc.Save(imgStream, SaveFormat.Png);

// Load this Image and place it in first header

Document docB = new Document();

using (Image img = Image.FromStream(imgStream))

{

double pageWidth = doc.Sections[0].PageSetup.PageWidth;

double pageHeight = doc.Sections[0].PageSetup.PageHeight;

docB.Sections[0].PageSetup.PageWidth = pageWidth;

docB.Sections[0].PageSetup.PageHeight = pageHeight;

DocumentBuilder builder = new DocumentBuilder(docB);

builder.MoveToHeaderFooter(HeaderFooterType.HeaderFirst);

Shape watermark = builder.InsertImage(img);

if (img.Width > pageWidth)

watermark.Width = pageWidth;

else

watermark.Width = img.Width - 50;

if (img.Height > pageHeight)

watermark.Height = pageHeight;

else

watermark.Height = img.Height - 50;

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

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

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

watermark.VerticalAlignment = Aspose.Words.Drawing.VerticalAlignment.Top;

}

// At this point clean watermark document is built

// Now merge the contents of the headers/footers

// in your template document and watermark document as follows

Document docA = new Document(@"C:\Temp\warn45.doc");

DocumentBuilder builderA = new DocumentBuilder(docA);

//Loop through all sections in the B document

foreach (Section sectB in docB.Sections)

{

Section sectA = null;

int sectBIndex = docB.Sections.IndexOf(sectB);

//Check whether document A conteins section with same index

if (docA.Sections.Count > sectBIndex)

{

//Get correcponding section

sectA = docA.Sections[sectBIndex];

}

else

{

//Insert empty section

builderA.MoveToDocumentEnd();

builderA.InsertBreak(BreakType.SectionBreakContinuous);

sectA = builderA.CurrentSection;

}

//Loop throught all Headers/Footers in the B document

foreach (HeaderFooter hfB in sectB.HeadersFooters)

{

//Check whether current section from docA conteins

//Header/Footer with the same type as h/f from docB

if (sectA.HeadersFooters[hfB.HeaderFooterType] != null)

{

//Append content from h/f B to h/f A

foreach (Node childB in hfB.ChildNodes)

{

//Import node

Node childA = docA.ImportNode(childB, true, ImportFormatMode.KeepSourceFormatting);

//Appent node to h/f

sectA.HeadersFooters[hfB.HeaderFooterType].AppendChild(childA);

}

}

else

{

//Copy whole h/f

Node hfA = docA.ImportNode(hfB, true, ImportFormatMode.KeepSourceFormatting);

//Insert h/f

sectA.HeadersFooters.Add(hfA);

}

}

}

//Save output document

docA.Save(@“C:\Temp\finalout.doc”);


I hope, this helps.

Best Regards,