博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
USE PDFCREATE TO CREATE A PDF FILE
阅读量:4364 次
发布时间:2019-06-07

本文共 2196 字,大约阅读时间需要 7 分钟。

来源:http://www.pdfforge.org/files/old_forum/1002.html

a working sample with C++ & COM

2007-08-15 22:56:18 by eckart

hi, 

here is a working sample of how to use PDFCreator in Visual C++ (after searching on internet for something similar I guess this is the only sample) 
This sample is reading c:\2.txt file and output to c:\pdf\2.pdf 
1. you need to #import 1 
#import "C:\WINDOWS\system32\MSVBVM60.DLL" rename ( "EOF", "VBEOF" ), rename ( "RGB", "VBRGB" ) //if you don't use this you will be in BIG trouble 
#import "C:\Program Files\PDFCreator\PDFCreator.exe" 
2. start your PDF engine 
::CoInitialize(NULL); 
CComPtr<pdfcreator::_clspdfcreator> pdfObject; 
HRESULT hr = pdfObject.CoCreateInstance(L"PDFCreator.clsPDFCreator"); 
if (!FAILED(hr)) 
if (pdfObject->cStart(L"/NoProcessingAtStartup", FALSE)==FALSE) 
AfxMessageBox("can't start printer"); 
return; 
}; 
PDFCreator::_clsPDFCreatorOptionsPtr opt= pdfObject->GetcOptions(); 
opt->PutUseAutosave(1); 
opt->PutUseAutosaveDirectory(1); 
opt->PutAutosaveDirectory(L"c:\\pdf\\"); //here you put your output folder 
opt->PutAutosaveFormat(0); //0 for PDF 
opt->PutAutosaveFilename(L"2.pdf"); //pdf output file name 
pdfObject->PutRefcOptions(opt); 
pdfObject->PutcDefaultPrinter(L"PDFCreator"); //use PDFCreator printer from ControlPanel->Printers 
pdfObject->cClearCache(); 
//pdfObject->cSaveOptions(L"1"); 
pdfObject->PutcPrinterStop(VARIANT_FALSE); //let's start with PDFCreator Printer Process Queue ON 
pdfObject->cPrintFile(L"c:\\2.txt"); //input of the file that will be translated into PDF format 
Sleep(4000); //lets wait for processing, TODO implement __clsPDFCreator_eReadyEventHandler 
BSTR fn = pdfObject->GetcOutputFilename(); //if your PDFCreator Printer is OFF you will get nothing "" 
AfxMessageBox(CString((const wchar_t*)fn)); 
pdfObject->cClose(); 
pdfObject.Release(); 
//--------------------------------
*tada* 
if this sample is not working I guess is not my fault ;-) 
thanks, 
--adi 
adrian.paleacu[a]gmail.[0m 


 

2008-12-16 10:56:50 by hwewet

Hi!

This sample works fine, but is it possible to do this
without the #import instructions ???
by the way, i dont want use the *.tlh *.tli files of course!

转载于:https://www.cnblogs.com/songtzu/p/3523154.html

你可能感兴趣的文章
Run “mvn clean install” in Eclipse
查看>>
实验二
查看>>
Jquery使用Id获取焦点和失去焦点
查看>>
Linux入门到放弃之七《进程管理》
查看>>
VS Code 简单配置运行Java
查看>>
Rectangle Intersection Test (with C#)
查看>>
c printf()详解[转载]
查看>>
03、 forms组件
查看>>
Win32++ Home Page
查看>>
织梦Dedecms使用Nginx的安全设置
查看>>
android中自定义shape
查看>>
8、JPA-映射-双向一对一
查看>>
Oracle查看表结构的几种方法
查看>>
1.MySql
查看>>
div+css 设计下拉
查看>>
模拟公交站台竖直排列,两端对齐
查看>>
JavaScript dom 标签属性
查看>>
CSS半透明边框
查看>>
进程上下文和中断上下文
查看>>
unity GUI GUILayout 水平 垂直布局
查看>>