Here's some old code which I had lying around. It might do exactly what you're looking for.

use strict; use Win32::OLE qw(in with); use Win32::OLE::Const 'Microsoft Word'; use Getopt::Std; my %opts; getopts('o:i:', \%opts); my $infile = $opts{i} || die "No input File specified - use -i file\n +"; my $outfile = $opts{o} || die "No output File specified - use -o file\ +n"; my $Word = Win32::OLE->new('Word.Application', 'Quit'); # $Word->{'Visible'} = 1; # if you want to see what's going on $Word->Documents->Open($infile) || die("Unable to open document ", Win32::OLE->LastError()); $Word->{DisplayAlerts}=-1; $Word->ActiveDocument->PrintOut({ Background => 0, Append => 0, Range => wdPrintAllDocument, Item => wdPrintDocumentContent, Copies => 1, PageType => wdPrintAllPages, OutputFileName => $outfile, PrintToFile => 1, }); $Word->ActiveDocument->Close(0); unlink $outfile; #The pdf creation appends ".pdf" to $outfile, but c +reates an empty $outfile as well

Then again, it might not. I've given up using Adobe Acrobat, and I'm now using Samba and ghostscript to do the same thing for free. See here if you're interested.


davis
It's not easy to juggle a pregnant wife and a troubled child, but somehow I managed to fit in eight hours of TV a day.

In reply to Re: Manipulating MSWord with Win32::OLE to convert a word document to pdf by davis
in thread Manipulating MSWord with Win32::OLE to convert a word document to pdf by ruhk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.