src/Pdf/Html/Backend.php
public function generate()
	{
		// Inject our print framework
		if ($this->printFramework !== false)
		{
			$this->document->setContents
			(
				Str::s($this->document->getContents())->replace
				(
					'</head>',
					$this->printFramework.'</head>'
				)
			);
		}

		// Create a new temp file for the generated pdf
		$output_document = $this->tempFile();

		// Build the cmd to run
		$cmd =
			$this->binary.' '.
			$this->runner.' '.
			'--url "file://'.$this->document->getPathname().'" '.
			'--output "'.$output_document->getPathname().'" '
		;

		if (isset($this->paperSize['width']))
		{
			$cmd .= '--width "'.$this->paperSize['width'].'" ';
		}

		if (isset($this->paperSize['height']))
		{
			$cmd .= '--height "'.$this->paperSize['height'].'" ';
		}

		// Run the command
		$process = $this->process($cmd);
		$process->run();

		// Check for errors
		if (!$process->isSuccessful())
		{
			throw new RuntimeException
			(
				$process->getErrorOutput()
			);
		}

		// Return the pdf
		return $output_document->getContents();
	}
public function generate()
	{
		// Inject our print framework
		if ($this->printFramework !== false)
		{
			$this->document->setContents
			(
				Str::s($this->document->getContents())->replace
				(
					'</head>',
					$this->printFramework.'</head>'
				)
			);
		}

		// Create a new temp file for the generated pdf
		$output_document = $this->tempFile();

		// Build the cmd to run
		$cmd =
			$this->binary.' '.
			$this->runner.' '.
			'--url "file://'.$this->document->getPathname().'" '.
			'--output "'.$output_document->getPathname().'" '
		;

		if (isset($this->paperSize['width']))
		{
			$cmd .= '--width "'.$this->paperSize['width'].'" ';
		}

		if (isset($this->paperSize['height']))
		{
			$cmd .= '--height "'.$this->paperSize['height'].'" ';
		}

		// Run the command
		$process = $this->process($cmd);
		$process->run();

		// Check for errors
		if (!$process->isSuccessful())
		{
			throw new RuntimeException
			(
				$process->getErrorOutput()
			);
		}

		// Return the pdf
		return $output_document->getContents();
	}
public function generate ( ) { // Inject our print framework if ( $ this -> printFramework !== false ) { $ this -> document -> setContents ( Str :: s ( $ this -> document -> getContents ( ) ) -> replace ( '</head>' , $ this -> printFramework . '</head>' ) ) ; } // Create a new temp file for the generated pdf $ output_document = $ this -> tempFile ( ) ; // Build the cmd to run $ cmd = $ this -> binary . ' ' . $ this -> runner . ' ' . '--url "file://' . $ this -> document -> getPathname ( ) . '" ' . '--output "' . $ output_document -> getPathname ( ) . '" ' ; if ( isset ( $ this -> paperSize [ 'width' ] ) ) { $ cmd .= '--width "' . $ this -> paperSize [ 'width' ] . '" ' ; } if ( isset ( $ this -> paperSize [ 'height' ] ) ) { $ cmd .= '--height "' . $ this -> paperSize [ 'height' ] . '" ' ; } // Run the command $ process = $ this -> process ( $ cmd ) ; $ process -> run ( ) ; // Check for errors if ( ! $ process -> isSuccessful ( ) ) { throw new RuntimeException ( $ process -> getErrorOutput ( ) ) ; } // Return the pdf return $ output_document -> getContents ( ) ; }
Generates the PDF from the HTML File

@return PDF Bytes
Generates the PDF from the HTML File