Solved

PHP MySQL - Using pdftk and PHP variables

Posted on 2008-10-19
1
1,587 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to submit record from external php form to a Sharepoint list? 5 56
Currency in SQL? 2 33
ajax to record click 3 16
Checking https returns 301 21 33
Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

820 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