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 7719121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T03:20:06+00:00 2026-06-01T03:20:06+00:00

I have the following code function generate_pdf() { $fdf_data_strings = $this->get_hash_for_pdf(); #$fdf_data_names = array(’49a’

  • 0

I have the following code

function generate_pdf() {

        $fdf_data_strings = $this->get_hash_for_pdf();
        #$fdf_data_names   = array('49a' => "yes");
        $fdf_data_names = array();
        $fields_hidden    = array();
        $fields_readonly  = array();
        $hud_pdf = ABSPATH.'../pdf/HUD3.pdf';

        $fdf= forge_fdf( '',
                 $fdf_data_strings,
                 $fdf_data_names,
                 $fields_hidden,
                 $fields_readonly );

        /*  echo "<pre>";
            print_r($fdf);
            echo "</pre>";
            die('');
        */

        $fdf_fn= tempnam( '.', 'fdf' );
        $fp= fopen( $fdf_fn, 'w' );
        if( $fp ) {
          fwrite( $fp, $fdf );
            //$data=fread( $fp, $fdf );
         // echo $data;
          fclose( $fp );


          header( 'Content-type: application/pdf' );
          header( 'Content-disposition: attachment; filename=settlement.pdf' ); // prompt to save to disk

          passthru( 'pdftk HUD3.pdf fill_form '. $fdf_fn.' output - flatten');

          unlink( $fdf_fn ); // delete temp file

        }
        else { // error
          echo 'Error: unable to open temp file for writing fdf data: '. $fdf_fn;
        }
    }
}

is there anything wrong with it?

the problem is, I have installed pdftk

runing whereis pdftk gives me '/usr/local/bin/pdftk'

physically checked the location, pdftk is there at the said location..

using terminal, if i run pdftk --version or any other command, it runs

if I use php like passthru('/usr/local/bin/pdftk --version') nothing is displayed

if I used php like system("PATH=/usr/local/bin && pdftk --version"); it says '/usr/local/bin /pdftk :there is no directory of file '

when I run this function script , prompt for file download pops, but when i save it, nothng is saved,

i have checked permission for this folder and changed it 0755, 0766, 0777, 0666 i have tried all, nothng works

For 3 days, i am striving to get over it, and I have asked question regarding this too, but Can’t figure out what the hell is going on with me.

Can somebody help me before i strike my head with wall?

  • 1 1 Answer
  • 3 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-01T03:20:07+00:00Added an answer on June 1, 2026 at 3:20 am

    The pasthru function does not execute the program through the shell.

    Pass the exact path into the passthru command.

    E.g.

    passthru( '/usr/local/bin/pdftk HUD3.pdf fill_form '. $fdf_fn.' output - flatten');
    

    or
    passthru( ‘/usr/local/bin/pdftk’ . $hud_pdf . ‘fill_form ‘. $fdf_fn.’ output – flatten’);

    If this still doesn’t work test using
    <?php passthru("/path/to/pdftk --help"); ?> where /path/to/pdftk is your path returned by which or where is, to ensure path is correct.

    If path is correct then the issue may be related to permissions either on the temporary directory you tell pdftk to use or the permissions on the pdftk binary with regards to the apache user.

    If these permissions are fine you can verify the pdftk starts up from php but hangs from running your command, then might be able to try the workaround listed here.

    Further documentation on passthru is avaliable passthru PHP Manual.

    As a side note, the putenv php function is used to set environment variables.

    E.g. putenv('PATH='.getenv('PATH').':.');

    All 3 PHP functions: exec(), system() and passthru() executes an external command, but the differences are:

    • exec(): returns the last line of output from the command and flushes nothing.
    • shell_exec(): returns the entire output from the command and flushes nothing.
    • system(): returns the last line of output from the command and tries to flush the output buffer after each line of the output as it goes.
    • passthru(): returns nothing and passes the resulting output without interference to the browser, especially useful when the output is in binary format.

    Also see PHP exec vs-system vs passthru SO Question.

    The implementation of these functions is located at exec.c and uses popen.

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

Sidebar

Related Questions

I have the following code: function Person(){ this.age = 30; } function Stats(){ this.age
I have the following code: function toggleChecked(status) { $(.checkbox).each( function() { $(this).attr(checked,status); }) }
I have the following jquery code: jQuery(function(){ jQuery(select#rooms).change(function(){ var options = ''; jQuery.getJSON(/admin/selection.php,{id: jQuery(this).val(),
I have the following code (generates a quadratic function given the a, b, and
I have the following code: function show(){ var a=document.getElementById('somediv').style.display; a=block; } The above code
Suppose I have the following code function myFunction(param, callback) { ... if (err) {
I have the following code: protected function safePath($path) { $path = (string) $path; $path
I have the following code: $(function () { $(#ARO).load('/DA.aspx?section=ARO #ARO', function() { DoSomething1(); });
I currently have the following js code function clearMulti(option) { var i; var select
I have used the following code to generate some dynamic checkboxes. This works for

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.