Solved

PHP MySQL - Using pdftk and PHP variables

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
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 …

757 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now