mikehaertl\wkhtmlto\Image::saveAs PHP Method

saveAs() public method

Save the image to given filename (triggers image creation)
public saveAs ( string $filename ) : boolean
$filename string to save image as
return boolean whether image was created successfully
    public function saveAs($filename)
    {
        if (!$this->_isCreated && !$this->createImage()) {
            return false;
        }
        if (!$this->_tmpImageFile->saveAs($filename)) {
            $tmpFile = $this->_tmpImageFile->getFileName();
            $this->_error = "Could not copy image from tmp location '{$tmpFile}' to '{$filename}'";
            return false;
        }
        return true;
    }

Usage Example

Example #1
0
 public function testCanUseXvfbRun()
 {
     $inFile = $this->getHtmlAsset();
     $outFile = $this->getOutFile('png');
     $binary = $this->getBinary();
     $image = new Image(array('binary' => $binary, 'commandOptions' => array('enableXvfb' => true)));
     $this->assertInstanceOf('mikehaertl\\wkhtmlto\\Image', $image->setPage($inFile));
     $this->assertTrue($image->saveAs($outFile));
     $tmpFile = $image->getImageFilename();
     $command = (string) $image->getCommand();
     $this->assertEquals("xvfb-run --server-args=\"-screen 0, 1024x768x24\" {$binary} '{$inFile}' '{$tmpFile}'", $command);
     unlink($outFile);
 }
All Usage Examples Of mikehaertl\wkhtmlto\Image::saveAs