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