无法使PDFMerger.php与界面一起使用

时间:2015-08-04 06:53:44

标签: php html user-interface pdf

我正在使用PDFMerger.php来完美地合并我的PDF文件,但是当我尝试为它创建一个接口时,我在最后一行上遇到语法错误。

原始代码(是否可以编辑此代码以使用我的界面而不是我创建的代码?):

<?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.
?>

这是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>

这是新的php文件,用于合并接口中的文件并进行检查:

<?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');
} 
?> 

以下是错误文字:

Parse error: syntax error, unexpected end of file in C:\xampp\htdocs\PDFMerger\merger.php on line 31

1 个答案:

答案 0 :(得分:0)

您在代码中遇到语法错误,错过了2 <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.js"></script> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bxslider/4.2.5/jquery.bxslider.js"></script> <div id="banner"> <div class="banner-nav"> <div class="banner-pager"> <a href="">Dubery Wotsit</a> <a href="">Laterz on a'menjey</a> <a href="">Joben</a> <a href="">Tukka Tukka</a> <a href="">Horse Hair Duvet</a> <a href="">FML</a> <a href="">Balls Deep</a> </div> </div> <div class="banner-wrap"> <ul id="banner-slider"> <li style="background: #FF0000;"> <div class="banner-slide">Dubery Wotsit</div> </li> <li style="background: #FF8000;"> <div class="banner-slide">Laterz on a'menjey</div> </li> <li style="background: #FFFF00;"> <div class="banner-slide">Joben</div> </li> <li style="background: #80FF00;"> <div class="banner-slide">Tukka Tukka</div> </li> <li style="background: #00FF00;"> <div class="banner-slide">Horse Hair Duvet</div> </li> <li style="background: #00FF80;"> <div class="banner-slide">FML</div> </li> <li style="background: #00FFFF;"> <div class="banner-slide">Balls Deep</div> </li> </ul> </div> </div>

}