读书人

Delphi怎么实现Word转换PDF后文件保

发布时间: 2012-10-30 16:13:36 作者: rapoo

Delphi如何实现Word转换PDF后,文件保存在指定路径?
用以下代码已经可以实现Word转PDF的功能,但要用户选择PDF存放位置后才能完成转换。
我想在程序里写明存放位置,这样就不用人工选择。但遇到以下问题,请大家帮忙看一下:谢谢

var
msword : OleVariant;

begin
msword:=createoleobject('word.application');
msword.documents.open('c:\test.doc');
msword.ActivePrinter := 'Adobe PDF';
msword.PrintOut;


1、用以下方法,可以在C盘生成pdf文件,但无法打开
msword.PrintOut(0, 0, 0,'c:\test.pdf');

2、用以下方法,运行时直接提示“类型不匹配”
msword.PrintOut(
OutputFileName,
Range,
Item,
Copies,
Pages,
PageType,
ManualDuplexPrint,
Collate,
Background,
PrintToFile,
PrintZoomColumn,
PrintZoomRow,
PrintZoomPaperWidth,
PrintZoomPaperHeight
)

3、用以下方法,运行时直接提示“参数值已超出可接受的范围”
msword.PrintOut(Background,
Append,
Range,
filename,
from,
to_,
Item,
Copies,
Pages,
PageType,
PrintToFile,
Collate,
FileName,
EmptyParam,
ManualDuplexPrint);

我想查PrintOut函数的参数到底有几个参数?我在csdn上找了2天也没有找到准确的说法,
我把查到的一个个试了,都不成功,会报错:如“类型不匹配”、“参数值已超出可接受的范围”。

[解决办法]
查一下PDF虚拟打印机中是否可以设置默认输出目录,Foxit PDF Printer 是可以的
[解决办法]
你确定你用过虚拟打印机?Zan Image 这个虚拟打印机是可以设置存放路径的

读书人网 >.NET

热点推荐