#!/usr/bin/perl -w use strict; use Cwd; use Win32::OLE qw(in with); use Win32::OLE::Const 'Microsoft Word'; use Win32::OLE::Variant; my $dir = shift || cwd(); my $word; eval {$word = Win32::OLE->GetActiveObject('Word.Application')}; die "Word not installed" if $@; unless (defined $word) { $word = Win32::OLE->new('Word.Application', 'Quit') or die "Cannot start Word"; } Win32::OLE->Option(Warn => 3); print STDERR "Open test.doc\n"; my $doc = $word->{'Documents'}->Open("$dir/test.doc"); print STDERR "save test.pdf\n"; $word->{'ActivePrinter'} = 'Acrobat PDFWriter'; $doc->PrintOut({ PrintToFile => 1, OutputFileName => "$dir/test.pdf", Background => 0, Append => 0, Range => wdPrintAllDocument, Item => wdPrintDocumentContent, Copies => 1, PageType => wdPrintAllPages, }); undef $doc; undef $word;