35, 'margin-right' => 10, 'margin-bottom' => 15, 'margin-left' => 15, 'header-spacing' => 5, 'enable-local-file-access' => true ]; public function __construct( private Pdf $knpSnappy ) {} /** * Default encoding options * @return array */ public function getDefaultOptions() { return $this->defaultOptions; } /** * Encode the given HTML content into PDF, and * return the encoded content * * @param string $html * @param array $options * @return string */ public function encode(string $html, array $options = []): string { $options = array_merge($this->defaultOptions, $options); return $this->knpSnappy->getOutputFromHtml($html, $options); } /** * Encode the given HTML content into PDF, * write it into a file at the given location, * and returns the file path * * @param string $html * @param string $path * @param array $options * @return string */ public function encodeToFile(string $html, string $path, array $options = []): string { $options = array_merge($this->defaultOptions, $options); $this->knpSnappy->generateFromHtml($html, $path, $options); return $path; } }