1.
ask:how to import only one com exe file:
answer:
#import "..\bin\PDFCreator.exe"
2.error:
debug\pdfcreator.tlh(1883): error C2146: 语法错误: 缺少“;”(在标识符“cOptionsNames”的前面)
it’s code is:
_CollectionPtr cOptionsNames;
__declspec(property(get=GetcPrinterStop,put=PutcPrinterStop))
fixed:
i write this code,before #import …
class _CollectionPtr{
public:
_CollectionPtr(struct _Collection* hr,bool f){
}
};
3.ask:how to used pdfcreator object
answer: this is my sample:
class _CollectionPtr{
public:
_CollectionPtr(struct _Collection* hr,bool f){
}
};
#import "..\bin\PDFCreator.exe"
// http://stackoverflow.com/questions/3449684/pdfcreator-will-print-tiff-instead-of-pdf
bool convert(const wchar_t* path,const wchar_t* dst_dir,const wchar_t* dst_filename){
const wchar_t* postfix = wcschr(path,L'.')+1;
if(!isSupport(postfix,true))
return false;
CComPtr<PDFCreator::_clsPDFCreator> pdfObject;
HRESULT hr = pdfObject.CoCreateInstance(L"PDFCreator.clsPDFCreator");
if(FAILED(hr)){
log::error_lasterror(__FILE__,__LINE__);
return false;
}
pdfObject->cStart("/NoProcessingAtStartup", 1);
PDFCreator::_clsPDFCreatorOptionsPtr opt = pdfObject->GetcOptions();
opt->UseAutosave = 1;
opt->UseAutosaveDirectory = 1;
opt->AutosaveDirectory = dst_dir;//保存路径
opt->AutosaveFormat = 0;
opt->PrintAfterSaving = 1;
opt->UpdateInterval = 0; //diable the update check
opt->PrintAfterSavingNoCancel = 1;
opt->PrintAfterSavingPrinter = "PDFCreator";
opt->PrintAfterSavingQueryUser = 0;
//if (FileTyp == 5)
//{
// opt.TIFFResolution = 72;
// }
opt->AutosaveFilename = dst_filename; //保存文件名
pdfObject->cOptions = opt;
pdfObject->cClearCache();
_bstr_t DefaultPrinter = pdfObject->cDefaultPrinter;
pdfObject->cDefaultPrinter = "PDFCreator";
hr = pdfObject->cPrintFile(path);
pdfObject->cPrinterStop = false;
MSG msg = {0};
while (GetMessage(&msg, NULL, 0, 0)) //C++ code
{
TranslateMessage(&msg);
DispatchMessage(&msg);
if(pdfObject->cCountOfPrintjobs == 0)
break;
}
//while(true)
//{
// Sleep(1000);
// if(pdfObject->cCountOfPrintjobs == 0)
// break;
//}
pdfObject->cPrinterStop = true;
pdfObject->cDefaultPrinter = DefaultPrinter;
pdfObject->cClose();
return true;
}
4. and so on
No comments:
Post a Comment