Justin
Justin

Reputation: 2530

Opening FDF local works, but not on server

On my LOCALHOST, I have a form that creates and FDF file... Also in that file it includes a 'full-path' -> 'http://localhost/example/example.pdf'.... So when I 'click the link' to open the FDF file within the browser, it loads the PDF with the FDF data inserted in the proper locations.

When I do this on my Linux Server (not local), when I click the FDF file to open it, it just OPENS the file, and renders text (fdf file) to the screen instead of 'opening' the fdf file.

Wondering if anyone can help me out with this process... I want to open the FDF file and so it opens the PDF file as well.

This is some code that I have done, but i have commented out the 'headers'... as I didn't think I needed headers when 'opening' a file, rather than rendering one to screen?

    $fdf = new fdf();
    //$response = $fdf->fdfMerge(APP_ROOT."/forms/test/FormTest.pdf", $_POST);
    $response = $fdf->renderFDF(DOMAIN."forms/test/FormTest.pdf", $_POST, $_POST['userId'], $_POST['contactId']);
    //var_dump($response);

    // Link DIRECTLY to the FDF file... 
    echo "Internal: <a href='". $response['internalPath'] ."'>". $response['internalPath'] ."</a><br />";
    echo "External: <a href='". $response['externalPath'] ."'>". $response['externalPath'] ."</a><br />";

    /*
    if(ini_get('zlib.output_compression'))
         ini_set('zlib.output_compression', 'Off');

    header("Pragma: public"); // required
    header("Expires: 0");
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header("Cache-Control: private", false); // required for certain browsers

    header("Content-Type: application/x-download");
    header("Content-Disposition: attachment; filename=".$response['fdfFile'].";" );

    header("Content-Length: ".$filesize($response['fdfFile'])."");
    header("Content-Transfer-Encoding: binary");

    ob_clean();
    flush();

    fopen($response['fullPath']);
    */

--- BROWSER RESPONSE FROM LINUX BOX ---

%FDF-1.2
%âãÃÓ
1 0 obj
<< 
/FDF << /Fields [ <</T(formId)/V(111)>><</T(userId)/V(23)>><</T(contactId)/V(2950)>><</T(firstName)/V(Justin)>><</T(lastName)/V(Geezer)>><</T(email)/V([email protected])>>] 
/F (https://www.example.com/forms/test/FormTest.pdf) /ID [ <bd71513804f75900e899f3be924b69ef>
] >> 
>> 
endobj
trailer
<<
/Root 1 0 R 

>>
%%EOF

Here is a ScreenShot, when I use the "HEADER" responses. enter image description here


Edit: If I download the FDF file from the server, and 'double-click' to open the file, it downloads the PDF file from the web and opens it fine.

Upvotes: 1

Views: 2151

Answers (1)

Abe Petrillo
Abe Petrillo

Reputation: 2447

Best guess is the fpdf can't write to a tmp directory, or the files it's using are some how blocked. Check your apache logs, and can you give an example of the text that is displayed on linux? There might be a white space or return key in your php file. for example

<?php
echo "woohoo";
?>
<?php
echo "second woohoo";
?>

In the middle with the closing and opening tags, there's a return key which can mess things up on linux but not windows (as windows ignores the special character that causes a new line).

Also, at the end of the fpdf generating code, dont close the tag, ie:

<?php
echo "second wooho";

Upvotes: 0

Related Questions