[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 193
  • Last Modified:

saving a pdf image to file

guys,
can you give me an idea for saving a pdf image to file.
i tried this way,
 open(outputfile, ">test1.pdf" ) or die "Cannot create $file_path: $!";
 print outputfile "$data";
 close(outputfile);
where $data is the result of a http request.
this gave me only a page with no data.
hope you can guide me the rightway.
0
jimr100
Asked:
jimr100
1 Solution
 
kanduraCommented:
how exactly did you get $data?
it's quite unnecessary to put $data in quotes.
if you're on windows, it's advisable to add "binmode outputfile;" right after the "open()".
minor stylistic recommendation: filehandles should either be in full caps, or you should use a private variable to hold it:

    open my $out, ">test1.pdf" or die "Cannot create $file_path: $!";
    binmode $out;
    print $out $data;
    close $out;
0
 
manav_mathurCommented:
<off-topic>
Why does it say on top "You may not collaborate on this question"
</off-topic>

0
 
TintinCommented:
If you are getting the PDF via http, then just do:

use LWP::Simple;
getstore("http://www.example.com/test1.pdf","/path/to/test1.pdf") or die "Can not retrieve test1.pdf $!\n";
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now