本文整理自网络,侵删。
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 用tidsmip和tidmessage发送邮件
Delphi android实例-录音与回放(播放mp3)(xe8+小米2)
Delphi提示‘error loading midas.dll’的原因及解决方案
Delphi实现使用tidhttp控件向https地址post请求
Delphi 检查程序是否在(vm,vpc等)虚拟机运行 Delphi(测试可用)
更多相关阅读请进入《Delphi》频道 >>