本文整理自网络,侵删。
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 winapi: getclassname - 获取指定窗口的类名
更多相关阅读请进入《Delphi》频道 >>