in reply to Converting .doc files to .pdf using perl

Just to make sure I need to use only Perl no other stuff

I reversed your thought process---instead of .doc to .pdf, think .pdf "from" .doc. This was my first stab at it:

#!/usr/bin/perl use strict; use Text::FromAny; use HTML::FromText; use PDF::FromHTML; my $tFromAny = Text::FromAny->new( file => '/root/Desktop/basic.doc'); my $text = $tFromAny->text; text2html($text); my $pdf = PDF::FromHTML->new( encoding => 'utf-8' ); $pdf->load_file(\$text); $pdf->convert( FontUnicode => 'Helvetica', LineHeight => 10, Landscape => 1, ); $pdf->write_file('/root/Desktop/target.pdf');

Replies are listed 'Best First'.
Re^2: Converting .doc files to .pdf using perl
by anonymized user 468275 (Curate) on May 13, 2011 at 12:32 UTC
    I wouldn't have understood the OP requirement to be that. Word can save files in .pdf format, so I would expect to produce the same results as that with Perl. .doc format is pretty unbreakable, whereas .docx can be parsed because it is nothing more than zipped tree of xml files. The only way I can think of is to automate Word into doing it from .doc, which is pretty horrible.

    One world, one people