delphi word转pdf两种方法。


 1 uses ComObj;
 2 procedure TForm1.Button1Click(Sender: TObject);
 3 var
 4    wdo,wdoc,wdocs : OleVariant;
 5 begin
 6   wdo := CreateOleObject('Word.Application');
 7   wdocs := wdo.Documents;
 8   wdo.ActivePrinter := 'Acrobat PDFWriter';
 9   wdoc := wdocs.Open('C:\docfile.docx');
10   //另存为的方法可以用saveas
11   wdoc.ExportAsFixedFormat('C:\pdffile.pdf',
12                         17, false,
13                         EmptyParam,
14                         EmptyParam,
15                          EmptyParam,
16                         EmptyParam, EmptyParam,
17                          true,
18                         true, true, true,
19                         true, false,
20                         EmptyParam);
21 
22  //虚拟打印机的方法
23  wdoc.PrintOut(0, 0, 0,'C:\pdffile.pdf');
24 
25 end;
 1 uses ComObj;
 2 procedure TForm1.Button1Click(Sender: TObject);
 3 var
 4    wdo,wdoc,wdocs : OleVariant;
 5 begin
 6   wdo := CreateOleObject('Word.Application');
 7   wdocs := wdo.Documents;
 8   wdo.ActivePrinter := 'Acrobat PDFWriter';
 9   wdoc := wdocs.Open('C:\docfile.docx');
10   //另存为的方法可以用saveas
11   wdoc.ExportAsFixedFormat('C:\pdffile.pdf',
12                         17, false,
13                         EmptyParam,
14                         EmptyParam,
15                          EmptyParam,
16                         EmptyParam, EmptyParam,
17                          true,
18                         true, true, true,
19                         true, false,
20                         EmptyParam);
21 
22  //虚拟打印机的方法
23  wdoc.PrintOut(0, 0, 0,'C:\pdffile.pdf');
24 
25 end;

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM