ruhk has asked for the wisdom of the Perl Monks concerning the following question:
This code seems to work except it outputs a pdf file that is 0 bytes. Any ideas why? Ive read all the documentation on Win32::OLE I can find however I find no listing of commands I can use such as the PrintOut command. Any ideas? Apologies ahead of time for my lack of perl skills.#!/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;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Manipulating MSWord with Win32::OLE to convert a word document to pdf
by VSarkiss (Monsignor) on Sep 10, 2003 at 20:26 UTC | |
|
Re: Manipulating MSWord with Win32::OLE to convert a word document to pdf
by davis (Vicar) on Sep 11, 2003 at 11:40 UTC | |
by kepster (Initiate) on Jan 27, 2006 at 15:55 UTC | |
by davis (Vicar) on Jan 28, 2006 at 19:06 UTC | |
|
Re: Manipulating MSWord with Win32::OLE to convert a word document to pdf
by guha (Priest) on Sep 11, 2003 at 15:53 UTC |