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

uuwcl 2008-04-07 04:54:01
将DOC,xls,gif,pcx等文件,通过PDFCreator.exe 进行PDF文件生成,程序实现
...全文
2516 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
ahumrli 2012-07-24
  • 打赏
  • 举报
回复
能再具体点吗?
weiweidongting87 2011-09-05
  • 打赏
  • 举报
回复
怎么弄啊
meiZiNick 2008-05-01
  • 打赏
  • 举报
回复
支持搂主,收藏
knowledge_Is_Life 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,然后才能考虑这个问题
内容概要:本文提出了一种基于改进扩散模型的高海拔地区新能源高波动出力场景生成方法,并提供了完整的Python代码实现。该方法针对高海拔地区风能、光伏等新能源出力波动剧烈、不确定性高的特点,通过优化扩散模型的结构与训练策略,有效捕捉历史数据的概率分布特征与时序相关性,从而生成高质量、多样化的出力场景。文中详细阐述了模型的数学推导、网络架构设计、损失函数优化及采样算法改进,并通过实验证明其在拟合精度、场景多样性与稳定性方面优于传统生成模型,为电力系统在高比例新能源接入下的规划、调度与风险评估提供了可靠的场景输入支持。; 适合人群:具备一定Python编程能力和机器学习基础,从事新能源发电预测、电力系统分析、智能优化、场景生成等方向研究的科研人员、高校研究生及工程技术人员。; 使用场景及目标:①用于高海拔地区风电、光伏出力的不确定性建模与多场景生成;②支撑含高渗透率新能源的电力系统随机优化调度、鲁棒决策与风险评估;③为相关学术研究、论文复现与算法改进提供可运行的技术方案与代码基础; 阅读建议:建议读者结合所提供的完整资源(代码、数据集、说明文档)进行实践操作,重点关注扩散模型的前向加噪与反向去噪过程的设计细节,以及如何将其适配于新能源时序数据的生成任务,通过参数调优与对比实验深入理解模型的生成机制与性能边界。
内容概要:本文围绕基于静态约束法的配电网电动汽车接入容量评估展开研究,提出了一种在新型电力系统背景下评估主动配电网对电动汽车承载能力的方法。研究通过构建数学模型,结合潮流计算与关键约束条件(如电压越限、线路过载等),量化分析配电网可承受的最大电动汽车充电负荷容量,旨在识别规模化电动汽车接入带来的潜在运行风险,并为电网规划与运行提供科学依据。文中配套提供了完整的Matlab代码实现,便于仿真验证与结果复现。此外,该研究与分布式光伏承载力评估、电动汽车可调能力分析等方向形成技术联动,展现了多主题协同的研究体系。; 适合人群:具备电力系统分析基础理论知识及Matlab编程能力的高校研究生、科研机构研究人员,以及从事新能源并网、智能配电网规划与运行等相关领域的工程技术人员。; 使用场景及目标:①用于学术研究中的模型复现与论文撰写支撑;②评估实际配电网中电动汽车大规模接入的可行性与安全边界,指导充电基础设施布局;③作为高校教学案例,帮助学生深入理解电网承载力评估的核心原理、建模方法与仿真技术; 阅读建议:建议结合文中提及的相关研究方向(如二阶锥规划、多面体聚合方法等)进行对比学习,充分利用所提供的Matlab代码与网盘资料开展仿真实验,重点关注约束条件的设定逻辑与潮流计算模块的实现细节,以深化对评估模型机理与工程应用价值的理解。
内容概要:本文围绕“考虑隐私保护的分布式联邦学习电力负荷预测研究”展开,提出了一种基于Python实现的联邦学习框架,旨在解决居民或行业电力负荷预测中用户电表数据隐私泄露的风险。该研究通过构建分布式机器学习模型,使各参与方在不共享原始数据的前提下协同训练全局模型,有效实现了数据“可用不可见”。文中详细阐述了联邦学习的整体架构设计、本地模型训练流程、参数加密传输与安全聚合机制,并结合差分隐私等技术进一步增强系统的隐私保护能力。同时,研究利用真实电力负荷数据集进行了实验验证,展示了方法在预测精度与隐私保障之间的良好平衡,并提供了完整的代码实例与复现指南,便于后续研究与应用拓展。; 适合人群:具备一定机器学习基础和电力系统背景知识,从事智慧能源、隐私计算或人工智能相关方向研究的研究生、科研人员及工程技术人员。; 使用场景及目标:① 实现跨区域、跨主体的电力负荷协同预测,打破数据孤岛;② 在确保用户用电数据隐私安全的前提下提升负荷预测准确性;③ 推动联邦学习在智能电网、需求响应、虚拟电厂等场景中的实际部署与应用。; 阅读建议:建议结合文中提供的Python代码与网盘资料进行动手实践,重点关注联邦学习的通信轮次设计、模型聚合算法(如FedAvg)的实现细节以及差分隐私噪声添加策略,深入理解其对模型性能与隐私强度的影响,为进一步优化与创新奠定基础。
VDA_Band_19.1_3rd edition_2026 English Inspection of Technical Cleanliness 内容概要:本文档为德国汽车工业协会(VDA)发布的第三版《技术清洁度检验:功能相关汽车部件的颗粒污染检测》(VDA 19.1),系统规范了汽车行业中零部件技术清洁度的检测方法与流程。文件涵盖从取样、提取、过滤到分析的全流程标准化操作,重点更新了干法提取(如 Stamp Test 和刷吸法)、小于50µm颗粒的检测、光学子系统和SEM/EDX标准分析方法,并引入统一材料分类体系以提升结果可比性。同时明确了“标准分析”与“自由检验”的区别,前者用于高兼容性检测,后者允许客户与供应商协商定制参数。文档还强化了对非可测组件的技术清洁保障、测量不确定度评估及方法验证的要求,并提供了多个实际案例支持应用落地。; 适合人群:适用于汽车制造业中从事质量控制、工艺开发、供应商管理及相关检测实验室的技术人员和管理人员,尤其适合具备一定质量管理或洁净度检测基础的专业人员。; 使用场景及目标:①用于制定和执行零部件清洁度检测标准;②指导 incoming/outgoing 检验及生产过程监控;③支持失效分析与质量改进项目;④作为企业内部审核和技术交流的依据; 阅读建议:建议结合VDA 19.2及其他相关标准配套使用,重点关注各章节中的起始参数设定、方法选择逻辑及附录中的检查表示例,在实际操作中同步开展方法验证与人员培训,确保检测结果的有效性和可追溯性。

16,550

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Creator Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

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

试试用AI创作助手写篇文章吧