I am using PDFMerger.php to merge my PDF files perfectly but when I try to make an interface for it, I keep getting a syntax error on the last line.
The original code (Is it possible to edit this code to work with my interface instead of what I have created? ):
<?php
include 'PDFMerger.php';
$pdf = new PDFMerger;
$pdf->addPDF('samplepdfs/one.pdf')
->addPDF('samplepdfs/two.pdf', '1-2')
->addPDF('samplepdfs/three.pdf', 'all')
->merge('download', 'TEST2.pdf');
//REPLACE 'file' WITH 'browser', 'download', 'string', or 'file' for output options
//You do not need to give a file path for browser, string, or download - just the name.
?>
Here is the interface in html:
<html>
<link href='login1.css' rel="stylesheet" type="text/css">
<body>
<form action="merger.php" method="post" enctype="multipart/form-data" name="form1" id="formWrap">
<h1>Compiler </h1><br />
<div id="form">
<br />
<center>
Upload your PDF files below: <br />
<br />
<input name="file[]" type="file" id="file[]" />
<br />
<input name="file[]" type="file" id="file[]" />
<br />
<input name="file[]" type="file" id="file[]" />
<br />
<input name="file[]" type="file" id="file[]" />
<br />
<br />
<input type="submit" name="Submit" value="Merge!" />
<br />
<br />
</center>
</a>
</form>
</body>
</html>
here is the new php file to merger the file from the interface and do checking:
<?php
include 'PDFMerger.php';
$pdf = new PDFMerger;
if ($pdf['file']) {
foreach($pdf['file']['type'] as $key => $value) {
$ispdf = end(explode(".",$pdf['file']['name'][$key]));
$ispdf = strtolower($ispdf);
if ($value && $ispdf=='pdf') {
//upload each file to the server
$filename = $pdf['file']['name'][$key];
$filename = str_replace(" ","",$filename);
$uploadfile = $uploaddir . $filename;
move_uploaded_file($pdf['file']['tmp_name'][$key], $uploadfile);
$pdf ->merge('download', 'TEST2.pdf');
}
?>
Here is the error text:
Parse error: syntax error, unexpected end of file in C:\xampp\htdocs\PDFMerger\merger.php on line 31