saving a pdf image to file

Posted on 2005-04-18
Last Modified: 2011-09-20
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";
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.
Question by:jimr100
    LVL 18

    Accepted Solution

    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;
    LVL 16

    Expert Comment

    Why does it say on top "You may not collaborate on this question"

    LVL 48

    Expert Comment

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

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

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
    I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now