'A4', // (210 mm by 297 mm) ); /** * Create new instance * * @param PhpWord $phpWord PhpWord object */ public function __construct(PhpWord $phpWord) { parent::__construct($phpWord); $this->tempDir = sys_get_temp_dir(); } /** * Get Font * * @return string */ public function getFont() { return $this->font; } /** * Set font. Examples: * 'arialunicid0-chinese-simplified' * 'arialunicid0-chinese-traditional' * 'arialunicid0-korean' * 'arialunicid0-japanese' * * @param string $fontName */ public function setFont($fontName) { $this->font = $fontName; return $this; } /** * Get Paper Size * * @return int */ public function getPaperSize() { return $this->paperSize; } /** * Set Paper Size * * @param string $pValue Paper size = PAPERSIZE_A4 * @return self */ public function setPaperSize($pValue = 9) { $this->paperSize = $pValue; return $this; } /** * Get Orientation * * @return string */ public function getOrientation() { return $this->orientation; } /** * Set Orientation * * @param string $pValue Page orientation ORIENTATION_DEFAULT * @return self */ public function setOrientation($pValue = 'default') { $this->orientation = $pValue; return $this; } /** * Get temporary storage directory * * @return string */ public function getTempDir() { return $this->tempDir; } /** * Set temporary storage directory * * @param string $pValue Temporary storage directory * @return self */ public function setTempDir($pValue = '') { if (is_dir($pValue)) { $this->tempDir = $pValue; } else { throw new Exception("Directory does not exist: $pValue"); } return $this; } /** * Save PhpWord to PDF file, pre-save * * @param string $pFilename Name of the file to save as */ protected function prepareForSave($pFilename = null) { $fileHandle = fopen($pFilename, 'w'); if ($fileHandle === false) { throw new Exception("Could not open file $pFilename for writing."); } return $fileHandle; } /** * Save PhpWord to PDF file, post-save * * @param resource $fileHandle * @throws Exception */ protected function restoreStateAfterSave($fileHandle) { fclose($fileHandle); } }