delphi word转pdf两种方法


本文整理自网络,侵删。

 
uses ComObj;
procedure TForm1.Button1Click(Sender: TObject);
var
   wdo,wdoc,wdocs : OleVariant;
begin
  wdo := CreateOleObject('Word.Application');
  wdocs := wdo.Documents;
  wdo.ActivePrinter := 'Acrobat PDFWriter';
  wdoc := wdocs.Open('C:\docfile.docx');
  //另存为的方法可以用saveas
  wdoc.ExportAsFixedFormat('C:\pdffile.pdf',
                        17, false,
                        EmptyParam,
                        EmptyParam,
                         EmptyParam,
                        EmptyParam, EmptyParam,
                         true,
                        true, true, true,
                        true, false,
                        EmptyParam);

 //虚拟打印机的方法
 wdoc.PrintOut(0, 0, 0,'C:\pdffile.pdf');

end;


方法2:
uses ComObj;
procedure TForm1.Button1Click(Sender: TObject);
var
   wdo,wdoc,wdocs : OleVariant;
begin
  wdo := CreateOleObject('Word.Application');
  wdocs := wdo.Documents;
  wdo.ActivePrinter := 'Acrobat PDFWriter';
  wdoc := wdocs.Open('C:\docfile.docx');
  //另存为的方法可以用saveas
  wdoc.ExportAsFixedFormat('C:\pdffile.pdf',
                        17, false,
                        EmptyParam,
                        EmptyParam,
                         EmptyParam,
                        EmptyParam, EmptyParam,
                         true,
                        true, true, true,
                        true, false,
                        EmptyParam);

 //虚拟打印机的方法
 wdoc.PrintOut(0, 0, 0,'C:\pdffile.pdf');

end;

相关阅读 >>

Delphi xe5 unicodestring的由来

Delphi 验证guid的函数

Delphi console程序中一种定时方法

Delphi 遍历目录

Delphi2010中tresourcestream流使用

Delphi 调用js脚本

Delphi整理二(object pascal语言)

Delphi winapi: getclassname - 获取指定窗口的类名

Delphi取得trichedit的光标当前位置

Delphi datasnap传输流/文件问题

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...