473,387 Members | 1,493 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

PDF won't open using PHP

I'm using PHP to collect html form inputs and populates form fields in a PDF document. After it populates the PDF with the inputs from the front-end html form It prompts you to "open or save the created pdf file. My problem is when Acrobat tries to open the PDF document, I get an error message stating "Acrobat can't open file, it is either damaged or is not a supported file type, like it was sent as an email attachment and not decoded properly." I can save the pdf file but when I tru to open after saving it still gives me the same error.

Below is the source code for pdf_form_fill.php this is where I think the error is... I also have a forge_fpf.php file and will post if you think the problem is in it. any help would be appreciated... thanks John


<?php
require_once( 'forge_fdf.php' );

$fdf_data_strings= array();
$fdf_data_names= array();

foreach( $_POST as $key => $value ) {
// translate tildes back to periods
$fdf_data_strings[ strtr($key, '~', '.') ]= $value;
}

$fields_hidden= array();
$fields_readonly= array();

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

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

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

passthru( 'pdftk formtx.5.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;
}


?>
Mar 26 '07 #1
0 1443

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: daniel d | last post by:
hi all, Im using VB 6.0 Pro, my DB is SQL server 2000 Eval edn. I am using stored procedures to get data from my DB. I am trying to open up a new recordset as a dynamic however it refuses to...
7
by: alberta soranzo | last post by:
i'm trying to send a mass-email using microsoft's list builder (http://www.bcentral.com/products/lb/default.asp). my html file is clean and the javascript links work fine in all browsers. when...
5
by: John Warner | last post by:
I have a wierd problem that I can't find any reference to in the knowledge base. I develop simple databases at the company where I work, and many of them are used by hundreds of employees. We all...
1
by: Alpha | last post by:
I have a Window based application that shows up still running in the task manager when I close it. It reaches the "this.close" statement and then it stops at the "}" at the section of the...
1
by: Regardt | last post by:
Microsoft windows .Net 2003 I have a mayor problem! My property window won't open. I tried using the dynamic help to open the property window, but with out success. (The dynamic help window...
1
by: Regardt | last post by:
Microsoft windows .Net 2003 I have a mayor problem! My property window won't open. I tried using to dynamic help to open the property window, but with out success. (The dynamic help window won't...
4
by: Susan Rice | last post by:
I'm new to using CString. Why won't the following compile? I'm using Microsoft Visual C++ 6.0 Line 37 which it complains about is the function: 37 CString ConvertFile(char *szFileName) I...
16
by: alexia.bee | last post by:
Hi all, In some weird reason, excel instance won;t die if i remove the comment from 4 lines of setting values into struct. here is a snipcode public...
12
by: tekctrl | last post by:
Environment; Win2K PC with 1Gb of RAM and plenty of HD space running Access 2002 Issue; Access presents a blank data entry form in the Forms view when the New Record icon is used. However, it...
12
by: godiva | last post by:
Hi, Last week one client had errors caused by another program which led the IT guys to wipe out and rebuild the hard drive on one particular computer. Prior to this happening, the people in this...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.