• 全部
  • VC综合技术
  • 互联网技术
  • MFC AppLauncher
  • .NET 技术
  • 界面
  • 进程
  • 算法
  • 硬件/系统
  • 数据库
  • VC++技术资源

◆◆◆VC怎样通过编程实现操作PDFCreator虚拟打印机进行PDF文件生成

uuwcl 2008-04-07 04:54:01
将DOC,xls,gif,pcx等文件,通过PDFCreator.exe 进行PDF文件生成,程序实现
...全文
2212 点赞 收藏 13
写回复
13 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
ahumrli 2012-07-24
能再具体点吗?
回复
weiweidongting87 2011-09-05
怎么弄啊
回复
meiZiNick 2008-05-01
支持搂主,收藏
回复
支持搂主,收藏
回复
uuwcl 2008-04-14
COM Interface

From Version 0.8.1 RC9 the PDFCreator has a COM Interface included. So it is possible to control the PDFCreator using the command line of any other application.
Nearly all possiblities of the program are available using the COM Interface. The COM Interface includes Public classes, Public properties, Public methods and Public events.
There are no UDTs used so the compalibility will not be broken with any upgrading of UDTs.
There are "self-documenting" names used so that no further description is needed.

If the COM Interface should be tested in server mode. All settings have to saved with function cSaveOptions or the changes will have no effect.

In the sub-directory "COM" (located in the PDFCreator folder), several examples for different programming languages can be found that will demonstrate the procedure.


Class: clsPDFCreator


Properties
Public Property Get cCountOfPrintjobs() As Long
Public Property Get cDefaultPrinter() As String
Public Property Let cDefaultPrinter(ByVal Printername As String)
Public Property Get cError() As clsPDFCreatorError
Public Property Get cErrorDetail(ByVal PropertyName As String) As Variant
Public Property Get cInstalledAsServer() As Boolean
Public Property Get cIsConverted() As Boolean
Public Property Let cIsConverted(ByVal Value As Boolean)
Public Property Get cIsLogfileDialogDisplayed() As Boolean
Public Property Get cIsOptionsDialogDisplayed() As Boolean
Public Property Get cOption(ByVal PropertyName As String) As Variant
Public Property Let cOption(ByVal PropertyName As String, ByVal Value As Variant)
Public Property Get cOptions() As clsPDFCreatorOptions
Public Property Set cOptions(ByVal Options1 As clsPDFCreatorOptions)
Public Property Get cOptionsNames() As Collection
Public Property Get cOutputFilename() As String
Public Property Get cPDFCreatorApplicationPath() As String
Public Property Get cPostscriptInfo(ByVal PostscriptFilename As String, ByVal PropertyName As String) As String ' Valid property names: BoundingBox, CreateFor, CreationDate, Creator, DocumentData, DocumentNeededResources, DocumentSuppliedResources, LanguageLevel, Orientation, PageOrder, Pages, TargetDevice, Title
Public Property Get cPrinterStop() As Boolean
Public Property Let cPrinterStop(ByVal Value As Boolean)
Public Property Get cPrintjobFilename(ByVal JobNumber As Long) As String
Public Property Get cPrintjobInfo(ByVal PrintjobFilename As String, ByVal PropertyName As String) As String
Public Property Get cPrintjobInfos(ByVal PrintjobFilename As String) As clsPDFCreatorInfoSpoolFile
Public Property Get cProgramIsRunning() As Boolean
Public Property Get cProgramRelease(Optional ByVal WithBeta As Boolean = True) As String
Public Property Get cStandardOption(ByVal PropertyName As String) As Variant
Public Property Get cStandardOptions() As clsPDFCreatorOptions
Public Property Get cVisible() As Boolean
Public Property Let cVisible(ByVal Value As Boolean)
Public Property Get cWindowState() As Long
Public Property Let cWindowState(ByVal Value As Long) ' Value must be '0 = normal' or '1 = minimize' or '2 = maximize'
Public Property Get cWindowsVersion() As String



Functions
Public Function cClose() As Boolean
Public Function cCloseRunningSession() As Boolean
Public Function cGetLogfile() As String
Public Function cGetPDFCreatorPrinters() As Collection
Public Function cIsPrintable(ByVal Filename As String) As Boolean
Public Function cReadOptions() As clsPDFCreatorOptions
Public Function cReadOptionsFromFile(ByVal INIFilename As String) As clsPDFCreatorOptions
Public Function cStart(Optional ByVal Params As String, Optional ByVal ForceInitialize As Boolean = False) As Boolean



Subroutines
Public Sub cAddPrintjob(ByVal PostscriptFilename As String)
Public Sub cClearCache()
Public Sub cClearLogfile()
Public Sub cCombineAll()
Public Sub cConvertPostscriptfile(ByVal InputFilename As String, ByVal OutputFilename As String)
Public Sub cDeletePrintjob(ByVal JobNumber As Long)
Public Sub cErrorClear()
Public Sub cMovePrintjobBottom(ByVal JobNumber As Long)
Public Sub cMovePrintjobDown(ByVal JobNumber As Long)
Public Sub cMovePrintjobTop(ByVal JobNumber As Long)
Public Sub cMovePrintjobUp(ByVal JobNumber As Long)
Public Sub cPrintFile(ByVal Filename As String)
Public Sub cPrintPDFCreatorTestpage()
Public Sub cPrintPrinterTestpage(Optional ByVal Printername As String)
Public Sub cSaveOptions(Optional ByVal Options1 As Variant) ' Options1 must be a clsPDFCreatorOptions type
Public Sub cSaveOptionsToFile(ByVal INIFilename As String, Optional ByVal Options1 As Variant) ' Options1 must be a clsPDFCreatorOptions type
Public Sub cSendMail(ByVal OutputFilename As String, ByVal Recipients As String)
Public Sub cShowLogfileDialog(ByVal Value As Boolean)
Public Sub cShowOptionsDialog(ByVal Value As Boolean)
Public Sub cTestEvent(ByVal EventName As String)
Public Sub cWriteToLogfile(ByVal LogStr As String)



Events
Public Event eError()
Public Event eReady()



10 event error messages exist:
-2 Unknown Event!
-1 Test Error Event.
1 The ActiveX-Server has not been started! Please use function "cStart()" to start the ActiveX-Server!
2 An instance of the PDFCreator is already running. It is not allowed to have more than one instance running!
3 Unknown Options Name '%1' in '%2'!
4 Ghostscript Error: '%1'!
5 The file '%1' could not be found!
6 No valid path '%1' was given!
7 The file '%1' is in use!
8 Function '%1': Options1 is not a 'clsPDFCreatorOptions' type!
9 No valid postscript file '%1' was given!

不会用,在VC6工具栏中引用pdfcreator.EXE系统提示错误
VC怎样通过COM操作pdfcreator阿
回复
cofanz 2008-04-14
[Quote=引用 7 楼 uuwcl 的回复:]
这个方法行吗,不是DOC哪怎么办阿
[/Quote]
office系列的都可以用这个方法。
回复
uuwcl 2008-04-13
这个方法行吗,不是DOC哪怎么办阿
回复
fox000002 2008-04-12
[Quote=引用 1 楼 scq2099yt 的回复:]
首先得PDFCreator支持将DOC,xls,gif,pcx转换成PDF,然后才能考虑这个问题
[/Quote]

显然不可能,pdfcreator 是靠 word 等软件才能识别 Doc 等格式的
回复
cofanz 2008-04-12
如果装的是Acrobat 7.0及以上版本,可以用下面的方法

BOOL Doc2PDF(LPCTSTR lpszSrcDoc, LPCTSTR lpszDstPDF)
{
HRESULT hr;
CLSID clsid;
IUnknown* pUnk = NULL;
IDispatch *pDispApp = NULL;
if (!PathFileExists(lpszSrcDoc))
return FALSE;
CLSIDFromProgID(L"PDFMakerAPI.PDFMakerApp", &clsid);
hr = ::GetActiveObject(clsid,NULL,&pUnk);
if (FAILED(hr)) //
hr = ::CoCreateInstance( clsid, NULL, CLSCTX_SERVER,
IID_IUnknown, (void**) &pUnk);
if (SUCCEEDED(hr))
{
hr = pUnk->QueryInterface(IID_IDispatch, (void**)&pDispApp);
if (FAILED(hr))
{
pUnk->Release();
return FALSE;
}
COleVariant vOpt(DISP_E_PARAMNOTFOUND, VT_ERROR);
COleVariant covFalse((short)FALSE);
COleVariant vTrue((short)TRUE);
CPDFMakerApp maker;
maker.AttachDispatch(pDispApp,FALSE);
/*SAFEARRAY *ar[2];
ar[0] = SafeArrayCreateVector(VT_BSTR,0,1);
ar[1] = SafeArrayCreateVector(VT_BSTR,0,1);
_bstr_t a(lpszSrcDoc);
_bstr_t b(lpszDstPDF);
LONG rgIndices = 0;
SafeArrayPutElement(ar[0],&rgIndices,(BSTR)a);
rgIndices = 0;
SafeArrayPutElement(ar[1],&rgIndices,(BSTR)b);*/
long ret = 1;
do {
ret = maker.CreatePDF(lpszSrcDoc,lpszDstPDF,
vOpt,covFalse,vTrue,covFalse,vOpt);
Sleep(100);
} while(ret != 0);

//ret = maker.CreatePDFFromMultipleFiles(ar);
//SafeArrayDestroy(ar[0]);
//SafeArrayDestroy(ar[1]);
pDispApp->Release();
pUnk->Release();
return ret;
}
return FALSE;
}
回复
吹雪 2008-04-12
看一下pdfcreator是否支持命令行参数,如果支持以参数来进行转换的话就createprocess搞定.
回复
uuwcl 2008-04-08
有代码吗?
回复
ToperRay 2008-04-08
就和普通的控制打印差不多。

回复
scq2099yt 2008-04-08
首先得PDFCreator支持将DOC,xls,gif,pcx转换成PDF,然后才能考虑这个问题
回复
相关推荐
发帖
VC/MFC
创建于2007-09-28

1.5w+

社区成员

VC/MFC相关问题讨论
申请成为版主
帖子事件
创建了帖子
2008-04-07 04:54
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……