getConfigFile())) { throw new sfException('The domPDF configuration file could not be found in ' . $this->getConfigFile()); } // Include the configuration file require_once ($this->getConfigFile()); // Instantiate the new DOMPDF class $this->setPDF(new DOMPDF()); // If input is passed in the constructor, set it here if (!empty($input)) $this->setInput($input); // Set the initial paper settings $this->setPaper(); } /** * Set the path to the domPDF configuration file * * @param string $config_file */ public function setConfigFile($config_file) { $this->config_file = $config_file; } /** * Gets the absolute path to the configuration file * * @return string */ public function getConfigFile() { if (substr($this->config_file, 0, 1) !== '/') { $this->setConfigFile(realpath(dirname(__FILE__)) . '/' . $this->config_file); } return $this->config_file; } public function setPDF($object) { $this->dompdf = $object; } /** * Returns the domPDF object * * @return object */ public function getPDF() { return $this->dompdf; } /** * The HTML input that will be converted to PDF * You can optionally include an actual file instead of a string * * @param string $input * @param boolean $is_string */ public function setInput($input, $is_string = true) { if ( (bool) $is_string === true) { $this->getPDF()->load_html($input); } else { $this->getPDF()->load_html_file($input); } } /** * Define either http:// or https:// to access your host * * @param string $protocol */ public function setProtocol($protocol) { $this->getPDF()->set_protocol($protocol); } /** * The URL to the site which hosts your CSS and images * Do not include http:// or https:// * * @param string $host */ public function setHost($host) { $this->getPDF()->set_host($host); } /** * Sets the base path for which to look for CSS files and images * * @param string $base_path */ public function setBasePath($base_path) { $this->getPDF()->set_base_path($base_path); } /** * Define the type of paper and orientation for domPDF to use * * @param string $paper * @param string $orientation */ public function setPaper($paper = 'letter', $orientation = 'portrait') { $this->getPDF()->set_paper($paper, $orientation); } /** * Converts the HTML string into a PDF * * @return binary */ public function render() { return $this->getPDF()->render(); } /** * Generates the PDF file based on our input * * @return binary */ public function execute() { // Render the output to PDF $this->render(); return $this->getPDF()->output(); } }