- 人气:
- 放大
- 缩小
- 二维码
- 赞赏
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;