Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

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/ 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.

Replies are listed 'Best First'.
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/ 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"; }


      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?

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2020-07-05 13:53 GMT
Find Nodes?
    Voting Booth?

    No recent polls found