Solved

PHP MySQL - Using pdftk and PHP variables

Posted on 2008-10-19
1
1,585 Views
Last Modified: 2013-12-13
I have an existing web app that uses PHP and MySQL.  One of the PHP scripts uses a program called pdftk (http://www.accesspdf.com/pdftk/) to merge multiple pdf files into one pdf file.

If I use the following code, it works perfectly.  But in the following code, I have to name a specific output file.  I want to use a variable to define the output pdf filename.

I have also listed the code that I have tried to use a PHP variable, but it does not work.

Any ideas on how I can use a variable to name the output file?
This is the working code, but uses a static filename for the output file (final.pdf):
<?php
 
passthru('/pdftk /singles/*.pdf cat output /singles/final.pdf');
 
?>
 
 
This is the code that I tried to use a variable to define the output file name, but does not work:
<?php
$dir = "/final/";
$case = "1800644105";
$final = $dir . $case;
passthru('/pdftk /singles/*.pdf cat output $final ');
 
?>

Open in new window

0
Comment
Question by:fastfind1
1 Comment
 

Accepted Solution

by:
fastfind1 earned 0 total points
ID: 22755959
With a little work, I found the solution myself:

$input = "/home/swipeweb/public_html/crm/cbacks/records/" . $case ."*.pdf";
$output = "/home/swipeweb/public_html/crm/rets/finished/" . $mid . "/" . $base5 ;
//$output = "/home/swipeweb/public_html/crm/rets/finished/" . $mid . "_" . $case . ".pdf" ;
$pdftk = '/home/swipeweb/public_html/crm/cbacks/pdftk ';

$makepdf =  $pdftk . $input . " cat output ".  $output;
passthru($makepdf);
0

Featured Post

ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question