note 110291 added to ref.fdf
| From: | MathieuDuQuebec | Date: | Mon, 08 Oct 2012 17:59:34 +0000 |
| Subject: | note 110291 added to ref.fdf | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-191189@lists.php.net to get a copy of this message | ||
I've had a hard time getting to do what I wanted to do -- eg. having PHP create the appropriate
.fdf file to insert the desired values into a PHP form's fields, which would open directly and
seamlessly in a browser window. This applies at least to Firefox 15.0.1.
[g8z at yahoo dot com 17-Oct-2004 04:46]: That post suggests the right way to do it, indeed a pure
PHP solution that doesn't require the FDF toolkit. But MIND YOU: When working on a local server
(either you're building a desktop web app or testing locally), the complete path to the
original pdf form HAS to include http:// in front of localhost. So to be
clear, in g8z example if you insert:
$form = 'localhost/path/my_pdf_form.pdf';
it won't work, the browser window will just remain blank, you'll get no error message
telling you that the PDF form's url isn't understood. So you need to use this instead:
$form = 'http://localhost/path/my_pdf_form.pdf';
Took me a lot of messing around to figure it out!
I'll give you an example of the code I used, simplified compared to g8z's one, remembering
that I'm using a localhost location. Note as well that you may need to only populate SOME of
the pdf form's fields, and not inserting anything in your PHP concerning other fields, leaving
it to the user to enter directly in the PHP form afterwards. It means you don't have to include
a whole bunch of (... empty...) <</T(Field_Name)/V( )>> everywhere.
<?php
header('Content-type: application/vnd.fdf');
echo "%FDF-1.2
%âãÃÃ
1 0 obj
<</FDF<</F(http://localhost/path/my_pdf_form.pdf)/Fields[<</T(Field1)/V(".$_POST['Content1'].")>>
<</T(Field2)/V(".$_POST['Content2'].")>>
<</T(Field3)/V(".$_POST['Content3'].")>>]>>/Type/Catalog>>
endobj
trailer
<</Root 1 0 R>>
%%EOF";
?>
(Note that I put break returns in my example, between the <</T()/V()>> elements; that
shouldn't be done in your PHP but had to be done to fit the comments section format here.)
----
Server IP: 69.147.83.199
Probable Submitter: 65.92.18.177
----
Manual Page -- http://www.php.net/manual/en/ref.fdf.php
Edit -- https://master.php.net/note/edit/110291
Del: integrated -- https://master.php.net/note/delete/110291/integrated
Del: useless -- https://master.php.net/note/delete/110291/useless
Del: bad code -- https://master.php.net/note/delete/110291/bad+code
Del: spam -- https://master.php.net/note/delete/110291/spam
Del: non-english -- https://master.php.net/note/delete/110291/non-english
Del: in docs -- https://master.php.net/note/delete/110291/in+docs
Del: other reasons-- https://master.php.net/note/delete/110291
Reject -- https://master.php.net/note/reject/110291
Search -- https://master.php.net/manage/user-notes.php