Acar has asked for the wisdom of the Perl Monks concerning the following question:
not well-formed (invalid token) at line 2, column 0,
#!/usr/bin/perl use strict; use warnings; use Data::Dumper; use File::Slurp; use PDF::FromHTML; my $temp_location = "tmp"; my $location = "converted"; my $pdf = PDF::FromHTML->new( encoding => 'utf-8' ); my $all_pdf = get_pdf(); convert_to_pdf($all_pdf); sub get_pdf { opendir DIR, $temp_location; my @files = grep !/^\.{1,2}$/, readdir(DIR); if( @files == 0 ) { print "\n No files at this time.\n\n"; } return \@files; closedir(DIR); } # End Sub sub convert_to_pdf { my $get_files = shift; foreach my $file ( @{$get_files} ) { # Loading from a file: $pdf->load_file($temp_location."/".$file); # Perform the actual conversion: $pdf->convert(); # Write to a file: $pdf->write_file($location."/".$file); } }# End Sub
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Converting all files in a directory to PDF
by NetWallah (Canon) on Oct 16, 2014 at 00:53 UTC | |
by Acar (Initiate) on Oct 16, 2014 at 01:31 UTC | |
by CountZero (Bishop) on Oct 16, 2014 at 06:26 UTC | |
by NetWallah (Canon) on Oct 16, 2014 at 03:25 UTC | |
by thewebsi (Scribe) on Oct 16, 2014 at 03:25 UTC | |
by NetWallah (Canon) on Oct 16, 2014 at 04:06 UTC |