src/Pdf.php
public function save($path = null)
	{
		$pdf = $this->backend->generate();
		
		// If no output path has been supplied save the file
		// in the same folder as the original template.
		if (is_null($path))
		{
			if (is_null($this->originalDocument))
			{
				// This will be thrown when someone attemtps to use
				// the save method when they have supplied a HTML string.
				throw new RuntimeException
				(
					'You must supply a path for us to save the PDF!'
				);
			}
			
			$ext = $this->originalDocument->getExtension();
			$path = Str::s($this->originalDocument->getPathname());
			$path = $path->replace('.'.$ext, '.pdf');
		}
		
		// Save the pdf to the output path
		if (@file_put_contents($path, $pdf) === false)
		{
			throw new RuntimeException('Failed to write to file "'.$path.'".');
		}
		
		// Return the location of the saved pdf
		return $this->file($path);
	}
public function save($path = null)
	{
		$pdf = $this->backend->generate();
		
		// If no output path has been supplied save the file
		// in the same folder as the original template.
		if (is_null($path))
		{
			if (is_null($this->originalDocument))
			{
				// This will be thrown when someone attemtps to use
				// the save method when they have supplied a HTML string.
				throw new RuntimeException
				(
					'You must supply a path for us to save the PDF!'
				);
			}
			
			$ext = $this->originalDocument->getExtension();
			$path = Str::s($this->originalDocument->getPathname());
			$path = $path->replace('.'.$ext, '.pdf');
		}
		
		// Save the pdf to the output path
		if (@file_put_contents($path, $pdf) === false)
		{
			throw new RuntimeException('Failed to write to file "'.$path.'".');
		}
		
		// Return the location of the saved pdf
		return $this->file($path);
	}
public function save ( $ path = null ) { $ pdf = $ this -> backend -> generate ( ) ; // If no output path has been supplied save the file // in the same folder as the original template. if ( is_null ( $ path ) ) { if ( is_null ( $ this -> originalDocument ) ) { // This will be thrown when someone attemtps to use // the save method when they have supplied a HTML string. throw new RuntimeException ( 'You must supply a path for us to save the PDF!' ) ; } $ ext = $ this -> originalDocument -> getExtension ( ) ; $ path = Str :: s ( $ this -> originalDocument -> getPathname ( ) ) ; $ path = $ path -> replace ( '.' . $ ext , '.pdf' ) ; } // Save the pdf to the output path if ( @ file_put_contents ( $ path , $ pdf ) === false ) { throw new RuntimeException ( 'Failed to write to file "' . $ path . '".' ) ; } // Return the location of the saved pdf return $ this -> file ( $ path ) ; }
Saves the generated PDF.

We call the backend class to generate the PDF for us.
Then we attempt to save those bytes to a permanent location.

@param string $path If not supplied we will create the PDF in the name
folder as the source document with the same filename.

@return SplFileInfo
Saves the generated PDF .