0

Possible Duplicate:
Merge PDF files with PHP

I need help merging/attaching pdf files, that are uploaded by a user using a normal html form and POST upload processing via php.

The file(s) that are uploaded shall be attached/merged with the (already existing) pdf in the mysql row containing the pdf as a blob.

Right now I am using this could for uploading the files. Uploading works fine, but I can't get to merge them with the existing pdf.

Code Source:

http://www.johnboy.com/scripts/merge-pdf-files-with-php/merge.phps

Can anybody please point me in the right direction? thanks!

Community
  • 1
  • 1
ultrix
  • 33
  • 4
  • Not really. I read that post. My problem is getting the mysql blob merged with the user's pdf file(s). So I am interested in that specific mysql part. – ultrix Aug 21 '12 at 08:33
  • just save blob to tmp file. merging part is same. – Peter Aug 21 '12 at 08:34
  • is file_get_contents the right way to do it? thanks – ultrix Aug 21 '12 at 08:44
  • file_put_contents('blob.pdf', $blob_data); – Peter Aug 21 '12 at 08:47
  • `$lieferschein = file_get_contents('http://somehost/test.pdf'); move_uploaded_file($lieferschein, "tmp/bla.pdf");` trying with a static file first, this isn't working. move_uploaded_file works with the pdf's from the input form tho... – ultrix Aug 21 '12 at 08:51
  • thank you. file_put_contents works. trying with the blob now... – ultrix Aug 21 '12 at 08:55

1 Answers1

0

Here is how it worked for me:

Create a get.php to fetch the file from the database and echo it together with the headers:

header("Content-length: $size");
header("Content-type: $type");
header("Content-Disposition: inline; filename=$name");
echo $content;

Then you can fetch the pdf from another php like this:

$tmp = file_get_contents("http://somehost/get.php?table=test&id=$id");
file_put_contents("tmp/$id.pdf", $tmp);

Finally, if you take the code from the link in my question, simply change this line:

$command = "pdftk tmp/$id.pdf $command output $output";
ultrix
  • 33
  • 4