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.
jimr100Asked:
Who is Participating?
 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.