Beefy Boxes and Bandwidth Generously Provided by pair Networks Frank
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Using PDF::WebKit

by halweitz (Novice)
on May 18, 2013 at 03:14 UTC ( #1034055=perlquestion: print w/ replies, xml ) Need Help??
halweitz has asked for the wisdom of the Perl Monks concerning the following question:

Hi folks, I installed and tested wkhtmltopdf from the command line and it works beautifully. Then I installed PDF::WebKit to automate the interaction in a Perl script. However, when I run the script I get this error

: Win32::Process::Create() at C:/Dwimperl/perl/vendor/lib/IPC/Run.pm line 2822

Here is my code

#!perl -w use PDF::WebKit; use File::Slurp qw( :all ) ; my $path = 'C:\\temp\\SPM7L413T7971.htm'; my $html = read_file($path); PDF::WebKit->configure(sub { # default `which wkhtmltopdf` $_->wkhtmltopdf('c:\\Program Files (x86)\\wkhtmltopdf\\'); # default 'pdf-webkit-' # $_->meta_tag_prefix('my-prefix-'); # $_->default_options->{'--orientation'} = 'Portrait'; }); my $kit = PDF::WebKit->new(\$html, page_size=>'Letter'); my $pdf = $kit->to_pdf; my $file = $kit->to_file('c:\\temp\\test2.pdf');

This is mostly a copy and paste from the cpan documentation but I am not sure about the configure subroutine.

Comment on Using PDF::WebKit
Download Code
Re: Using PDF::WebKit
by Anonymous Monk on May 18, 2013 at 08:41 UTC
    See IPC::Run for a debug/warnings/logging option and turn it on

    other option, run debugger or edit PDF/WebKit.pm and Dumper out the args to IPC::Run::run( \@args, "<", \$input, ">", \$output );

    Then you/we can start to figure out the whats what what

Re: Using PDF::WebKit
by Anneq (Vicar) on May 18, 2013 at 18:33 UTC

    Are your @INC paths and environment variables at the command line, the same as through another script? Try putting this at the top of your script (before using Win32::Process::Create) and run in both scenarios:

    use strict; use warnings; $|=1; # Buffering BEGIN { print "#### Environment Variables ####\n"; foreach (keys(%ENV)) { print "$_ = $ENV{$_}\n"; } print "#### \@INC ####\n"; foreach(@INC) { print "$_\n"; } die "#### And there you go. Your info should be displayed below: +####\n"; }

    Anne

      Ok, here is the answer: The configure subroutine should have a line that looks like this:

      $_->wkhtmltopdf('c:\\Program Files (x86)\\wkhtmltopdf\\wkhtmltopdf.exe');

      The last wkhtmltopdf.exe was left off. The documentation says path/to/wkhtmltopdf and I didn't include the actual executable name. Oops. Thanks for all the suggestions.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1034055]
Approved by bulk88
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2014-04-18 08:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (464 votes), past polls