#!/usr/bin/perl 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', sub { $_[0]->Quit; }) or die "Cannot start Word"; } Win32::OLE->Option(Warn => 3); print STDERR "Open resume.html\n"; my $doc = $word->{'Documents'}->Open("$dir/resume.html"); # Shrink headings my $style = $doc->Styles('Heading 2'); $style->{'Font'}->{'Size'} = 16; # Remove color and underlining from hyperlinks $style = $doc->Styles('Hyperlink'); $style->{'Font'}->{'Color'} = wdColorAutomatic; $style->{'Font'}->{'Underline'} = wdUnderlineNone; undef $style; # Change side margins to 1 inch my $page = $doc->{'PageSetup'}; $page->{'LeftMargin'} = 72; $page->{'RightMargin'} = 72; #print "Top Margin: ", $page->{'TopMargin'}, "\n"; #print "Left Margin: ", $page->{'LeftMargin'}, "\n"; #print "Right Margin: ", $page->{'RightMargin'}, "\n"; #print "Bottom Margin: ", $page->{'BottomMargin'}, "\n"; #print "Page Height: ", $page->{'PageHeight'}, "\n"; #print "Page Width: ", $page->{'PageWidth'}, "\n"; # Save in .doc and .rtf formats print STDERR "Write resume.doc\n"; $doc->SaveAs("$dir/resume.doc", { 'FileFormat' => wdFormatDocument }); print STDERR "Write resume.rtf\n"; $doc->SaveAs("$dir/resume.rtf", { 'FileFormat' => wdFormatRTF }); # Print to PostScript file print STDERR "Print resume.ps\n"; $word->{'ActivePrinter'} = 'PS File'; $doc->PrintOut({ PrintToFile => 1, OutputFileName => "$dir/resume.ps", Background => 0, Append => 0, Range => wdPrintAllDocument, Item => wdPrintDocumentContent, Copies => 1, PageType => wdPrintAllPages, }); #print STDERR "Print resume.pdf\n"; #$word->{'ActivePrinter'} = 'PDF File'; #$doc->PrintOut({ # PrintToFile => 1, # OutputFileName => "$dir/resume.pdf", # Background => 0, # Append => 0, # Range => wdPrintAllDocument, # Item => wdPrintDocumentContent, # Copies => 1, # PageType => wdPrintAllPages, # }); undef $doc; undef $word;