Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8076561
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T15:17:05+00:00 2026-06-05T15:17:05+00:00

I need to call Ghostscript in one of our cgi to convert a PDF

  • 0

I need to call Ghostscript in one of our cgi to convert a PDF file to a PNG image. This cgi has the encoded PDF stream in the request then decodes it, like

my $PDF_ENCODED = $q->param('PDF_ENCODED');
my $PDF_DECODED = decode_base64($PDF_ENCODED);

and it will generate a PNG image on the disk by calling ‘gs’ command.

My problem is I do not know how to pipe the $PDF_DECODED to gs command line. I have tried

system("$PDF_DECODED | gs -dNOPAUSE -q -r300 -sDEVICE=png16m -dBATCH -sOutputFile=/tmp/ghostscript/new-test.png-")

But it is not working.

Thanks.

Thanks again, golimar and simbabque.
It is working with

$SIG{PIPE} = 'IGNORE';
open(FH, "| gs -dNOPAUSE -q -r300 -sDEVICE=png16m -dBATCH -sOutputFile=/tmp/ghostscript/new-test.png -")  or die "can't fork: $!";
print FH "$PDF_DECODED\n"   or die "can't write: $!";
close FH            or die "can't close: status=$?";
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T15:17:06+00:00Added an answer on June 5, 2026 at 3:17 pm

    In Perl you can open processes as if they were files, and when you write to the “file” handle, instead of writing data to a file, you are piping data to a process, see Using open() for IPC in perlipc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I need call this functions one after other, $('#art1').animate({'width':'1000px'},1000); $('#art2').animate({'width':'1000px'},1000); $('#art3').animate({'width':'1000px'},1000); I know
I need to call an API function after validating a form with is_valid(). This
I need to call class method in separate thread. The method has a parameter
I need to call this method, but I can't find it in any namespace.
I need to call a function on a using jquery. This function needs to
I need to call this from the code behind if there is a certain
When do I actually need call this method Runtime.getRuntime().addShutdownHook() and when or why I
I need to call a Perl script from a PHP file, and I've gotten
I've been using ghostscript to do pdf to image generation of a single page
I need call a DLL file in my delphi code, here is the code

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.