Solved

PHP MySQL - Using pdftk and PHP variables

Posted on 2008-10-19
1
1,600 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

This article discusses four methods for overlaying images in a container on a web page
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

738 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