title: Merging PDF files with PHP/FPDI
body: <p>i am trying to merge two files using <a href="http://www.setasign.com/products/fpdi/downloads/" rel="nofollow">FPDI</a>  the error i get is:'TCPDF ERROR: File is encrypted!',  however, the files are not encrypted, at least the files are printable, viewable etc and no password is required.</p>
  
  <p>i want to merge two files:</p>
  
  <p><a href="http://www.nps.org.au/__data/cmi_pdfs/CMI7412.pdf" rel="nofollow">http://www.nps.org.au/__data/cmi_pdfs/CMI7412.pdf</a>
  <a href="http://www.nps.org.au/__data/cmi_pdfs/CMI6656.pdf" rel="nofollow">http://www.nps.org.au/__data/cmi_pdfs/CMI6656.pdf</a></p>
  
  <p>after i copy the files to the server and store the file names in array ($files) that has the absolute file paths, my code is:</p>
  
  <pre><code>if (count ($files) &gt; 0 )
  {
      $pdf = new FPDI();
      $pdf-&gt;setPrintHeader(FALSE);
      $pdf-&gt;setPrintFooter(FALSE);
      foreach ($files as $file)
      {
          for ($i = 0; $i &lt; count($files); $i++ )
          {
              $pagecount = $pdf-&gt;setSourceFile($files[$i]);
              for($j = 0; $j &lt; $pagecount ; $j++)
              {
                  $tplidx = $pdf-&gt;importPage(($j +1), '/MediaBox');
                  $specs = $pdf-&gt;getTemplateSize($tplidx);
                  if ( $specs['h'] &gt; $specs['w'] )
                  {
                      $orientation = 'P';
                  }
                  else
                  {
                      $orientation = 'L';
                  }
                  $pdf-&gt;addPage($orientation,'A4');
                  $pdf-&gt;useTemplate($tplidx, 0, 0, 0, 0, TRUE);
              }
          }
          $output = $pdf-&gt;Output('', 'S');
          foreach ( $files as $file )
          {
              delete_file($file);
          }
      }
  </code></pre>
  
  <p>I have also tried to merge the files using ghostscript, but with no luck.
  I tried acrobat pro, which required a password for one file, but when I used mac preview, i exported the file and was able to merge it using acrobat with no issues.  i.e. mac preview removed the protection with no problems.
  So, what is it about the file CMI7412.pdf that stops merging, but not exporting, viewing, printing? and how can i get around it?</p>