I am using Microsoft Office Document Image Writer to convert a word document to a tiff file. The problem is that ever time it saves a file it shows it in a preview window. So I like to know if there's a way to prevent it from showing this preview window?
here's the code :
const string printerName = "Microsoft Office Document Image Writer";
var app = new ApplicationClass();
object filename = "C:\\ad.docx";
docName = "ad.docx";
var missing = Type.Missing;
object trueValue = true;
object falseValue = false;
var doc = app.Documents.Open(ref filename, ref missing, ref trueValue, ref falseValue, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
app.ActivePrinter = printerName;
fileSystemWatcher.Created += FileCreated;
fileSystemWatcher.EnableRaisingEvents = true;
object outputFileName = "c:\\Result\\ad.tif";
key = outputFileName.ToString();
_wait = new AutoResetEv开发者_StackOverflow中文版ent(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);
_wait.WaitOne();
doc.Close(ref missing, ref missing, ref missing);
app.Quit(ref missing, ref missing, ref missing);
I didn't find a programmatic way of doing this, but on a one time basis, uncheck View Document Image from the Save As dialog.
- Open any Word document; it's a test document and you can trash it afterwards.
- Select File->Print.
- Remember the name of the printer, you'll need it again.
- From the Name drop down list, select Microsoft Office Image Writer.
- Click the Properties button.
- Select the Advanced tab.
- Select the TIFF - Monochrome Fax option.
- Click OK and OK again.
- Optionally select a new location for the file that is about to be saved.
- Unclick View Document Image.
- Click Save. This is a trash file and can be thrown away afterwards.
- Select File->Print from the same Word document
- From the Name drop down list, select the name of the printer from remembered from step c.
- Click OK. This is a trash print and can be thrown away afterwards.
精彩评论