给你一个思路.可将word打印到FAX,可得TIF图像,以下是我用VC写的
word 转 fax文件
系统下必须有传真打印机(windows 2000安装)
以在是window 2000/office 2000/vc6.0中测试成功
void CTest1Dlg::OnButton1()
{
// TODO: Add your control notification handler code here
CoInitialize(NULL);
_Application oWord ;
Documents oDocs;
_Document oDoc;
COleDispatchDriver oWordBasic;
COleVariant vOpt(DISP_E_PARAMNOTFOUND, VT_ERROR); //For optional args
COleVariant vFalse(short(false));
COleVariant vTrue(short(true));
//Start Word
if(!(oWord.CreateDispatch("Word.Application", NULL)))
{
AfxMessageBox("Error starting Word.", MB_SETFOREGROUND);
return;
}
//Open a document
oDocs = oWord.GetDocuments();
oDoc = oDocs.Open(COleVariant("d://temp//test1//t.doc"
,vFalse,vFalse,vFalse,
vOpt, vOpt,vOpt, vOpt, vOpt, vOpt,vOpt,vOpt);
oWordBasic = oWord.GetWordBasic();
HRESULT hr;
OLECHAR FAR* szMethod[3];
DISPID dispid[3];
//Retrieve the DISPIDs for the function as well as two of its named
//arguments, Printer and DoNotSetAsSysDefault
szMethod[0]=OLESTR("FilePrintSetup"
; //method name
szMethod[1]=OLESTR("Printer"
; //argument name
szMethod[2]=OLESTR("DoNotSetAsSysDefault"
; //argument name
hr = oWordBasic.m_lpDispatch->GetIDsOfNames(IID_NULL, szMethod, 3,
LOCALE_USER_DEFAULT, dispid);
//Invoke the FilePrintSetup function using named arguments.
VARIANT vArgs[2];
DISPPARAMS dp;
dp.cArgs = 2;
dp.cNamedArgs = 2;
dp.rgvarg = vArgs;
dp.rgdispidNamedArgs=&(dispid[1]);
vArgs[1].vt = VT_I2;
vArgs[1].iVal = 1; //DoNotSetAsSysDefault = 1
vArgs[0].vt = VT_BSTR;
vArgs[0].bstrVal = ::SysAllocString(OLESTR("传真"
);
//NOTE: You should replace "Generic / Text Only" in the line
//above with the name of a printer installed on your system.
hr = oWordBasic.m_lpDispatch->Invoke(dispid[0], IID_NULL,
LOCALE_USER_DEFAULT,DISPATCH_METHOD, &dp, NULL, NULL, NULL);
::SysFreeString(vArgs[0].bstrVal);
//Print the document
oDoc.PrintOut(COleVariant((short)false), vOpt, vOpt, COleVariant("d://temp//test1//t.tif"
,
vOpt, vOpt, vOpt, vOpt, vOpt, vOpt, vTrue,
vOpt, vOpt, vOpt, vOpt, vOpt, vOpt, vOpt);
// oDoc.PrintOut(1,2,3,4,5,6,7,8,9,10,11
oDoc.Close(COleVariant((short)false), vOpt, vOpt);
//Clean-up
oDoc.ReleaseDispatch();
oDocs.ReleaseDispatch();
// oWordBasic.ReleaseDispatch();
//Quit Word
oWord.Quit(COleVariant((short)false), vOpt, vOpt);
}
参考文档
http://support.microsoft.com/?kbid=252719
当然,这种方法也可得到彩色的图像,在系统是设一HP 彩打(支持PS)的,如HP Color LaserJet 5/5M PS,并设打印到文件,同样用上面的程序,可将文件打印到一PS文件,然后用gsview将它转成你要的图像格式
最简的方法,安装一VirtualPrinter,可直接将word打印成图像