I am using a virtual printer to print a word document into an image file in a C# program. So far everything is going fine except that I don't know when the printing process is finished so I can read the content of the generated image. Here's my code :
using System;
using Microsoft.Office.Interop.Word;
using Word=Microsoft.Office.Interop.Word;
var app = new ApplicationClass();
object filename = "C:\\ad.doc";
var missing = Type.Missing;
var doc = app.Documents.Open(ref filename, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
var oldPrinter = app.ActivePrinter;
app.ActivePrinter = "Name of printer";
object outputFileName = "c:\\ad.tif";
object trueValue = true;
object falseValue = false;
doc.PrintOut(ref trueValue, ref falseValue, ref missing, ref outputFileName, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing, ref trueValue, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing, ref missing);
app.ActivePrinter=oldPrinter ;
doc.Close(ref missing, ref missing, ref missing);
app.Quit(ref missing, ref missing, ref missing);
Then how can I be sure that the print processing is finished so I can continue and get the image content?