Skip to content

Instantly share code, notes, and snippets.

@melice
Created October 16, 2017 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save melice/c1d0239506417f82ee2b5a5251e743ff to your computer and use it in GitHub Desktop.
Save melice/c1d0239506417f82ee2b5a5251e743ff to your computer and use it in GitHub Desktop.
office word docx save to pdf
program word2pdf;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils,
System.Variants,
System.Win.ComObj,
Word2000,
Vcl.OleServer;
const
wdExportFormatPDF = 17;
var
Word, Doc: OleVariant;
begin
if ParamCount <> 2 then exit;
try
Word := CreateOLEObject('Word.Application');
Doc := Word.Documents.Open( paramstr(1) );
Doc.ExportAsFixedFormat( paramstr(2) , wdExportFormatPDF);
Word.ActiveDocument.Close(wdDoNotSaveChanges);
finally
{ Quit Word }
Word.Quit;
Word := Unassigned;
end;
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment