Example #1
0
 /**
  * Save the PDF to given filename (triggers PDF creation).
  *
  * @param string $filename to save PDF as
  * @return bool whether PDF was created successfully
  */
 public function saveAs($filename)
 {
     if (!$this->_isCreated && !$this->createPdf()) {
         return FALSE;
     }
     if (!$this->_tmpPdfFile->saveAs($filename)) {
         $this->_error = "Could not save PDF as '{$filename}'";
         return FALSE;
     }
     return TRUE;
 }
Example #2
0
 public function testCanSaveFileAs()
 {
     $out = __DIR__ . '/test.txt';
     $content = 'test content';
     $tmp = new File($content);
     $fileName = $tmp->getFileName();
     $this->assertTrue($tmp->saveAs($out));
     $this->assertFileExists($out);
     $readContent = file_get_contents($out);
     $this->assertEquals($content, $readContent);
     unset($tmp);
     $this->assertFileNotExists($fileName);
     $this->assertFileExists($out);
 }
Example #3
0
 public function testCanKeepTempFile()
 {
     $out = __DIR__ . '/test.txt';
     $content = 'test content';
     $tmp = new File($content);
     $tmp->delete = false;
     $fileName = $tmp->getFileName();
     $this->assertFileExists($fileName);
     $this->assertTrue($tmp->saveAs($out));
     $this->assertFileExists($out);
     unset($tmp);
     $this->assertFileExists($fileName);
     $this->assertFileExists($out);
     unlink($out);
 }