?
Solved

PHP MySQL - Using pdftk and PHP variables

Posted on 2008-10-19
1
Medium Priority
?
1,607 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

770 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