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 xe10.2 firedac 三种连接

Delphi 用tidsmip和tidmessage发送邮件

Delphi异常重启自身

dededl安卓中保持屏幕常亮

Delphi android实例-录音与回放(播放mp3)(xe8+小米2)

Delphi idhttp 获取链接连通状态

Delphi提示‘error loading midas.dll’的原因及解决方案

Delphi实现使用tidhttp控件向https地址post请求

Delphi 检查程序是否在(vm,vpc等)虚拟机运行 Delphi(测试可用)

windows 消息

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



打赏

取消

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

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

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

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

评论

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