I have an automation application that adds a custom Watermark image to a document. After the watermark image is added, when the user types information into the document, the display of the characters lags behind the typing by a second or two. This is very annoying to power typist. This only happens when the image is visable (i.e. Print View) and not in Draft View. If I add the watermark image manually to a document, the typing delay does not occur.
The following is the code fragment that addes the Watermark image:
private void addWatermark(Word.Document doc)
{
object refmissing = System.Reflection.Missing.Value;
string watermarkPath = Path.Combine(Directory.GetCurrentDirectory(), "Watermark.jpg");
if (File.Exists(watermarkPath))
{
object linkToFile = false;
object saveWithDocument = true;
doc.ActiveWindow.View.SeekView = Word.WdSeekView.wdSeekCurrentPageHeader;
Word.WdHeaderFooterIndex hfIndex = Word.WdHeaderFooterIndex.wdHeaderFooterPrimary;
Word.HeaderFooter headerFooter;
if (doc.Sections[1].Headers != null)
{
headerFooter = doc.Sections[1].Headers[hfIndex];
}
else if (doc.Sections[1].Footers != null)
{
headerFooter = doc.Sections[1].Footers[hfIndex];
}
else
{
headerFooter = null;
}
if (headerFooter != null)
{
try
{
Word.Shape watermarkShape;
watermarkShape = headerFooter.Shapes.AddPicture(watermarkPath, ref linkToFile, ref saveWithDocument, ref refmissing,
ref refmissing, ref refmissing, ref refmissing, ref refmissing);
}
catch (System.Runtime.InteropServices.COMException e)
{
Debug.WriteLine(String.Format("{0} - Error Code = {1}", e.Message, e.ErrorCode));
throw e;
}
}
this.word.ActiveWindow.View.SeekView = Microsoft.Office.Interop.Word.WdSeekView.wdSeekMainDocument;
this.word.ActiveWindow.ActivePane.View.Type = Microsoft.Office.Interop.Word.WdViewType.wdPrintView;
}
else
{
Debug.WriteLine("Could not find watermark image");
}
}
I'm using Visual Studio 2008, and the Microsoft Word 12.0 Object Library. The image is a black and white jpeg this is 8.5" x 11".
How can I fix this?
DDrabo