ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
PHPExcel_Writer_PDF Class Reference
+ Inheritance diagram for PHPExcel_Writer_PDF:
+ Collaboration diagram for PHPExcel_Writer_PDF:

Public Member Functions

 __construct (PHPExcel $phpExcel)
 Create a new PHPExcel_Writer_PDF.
 setFont ($fontName)
 Set font.
 getPaperSize ()
 Get Paper Size.
 setPaperSize ($pValue=PHPExcel_Worksheet_PageSetup::PAPERSIZE_LETTER)
 Set Paper Size.
 getOrientation ()
 Get Orientation.
 setOrientation ($pValue=PHPExcel_Worksheet_PageSetup::ORIENTATION_DEFAULT)
 Set Orientation.
 save ($pFilename=null)
 Save PHPExcel to file.
 getTempDir ()
 Get temporary storage directory.
 setTempDir ($pValue= '')
 Set temporary storage directory.
- Public Member Functions inherited from PHPExcel_Writer_HTML
 getSheetIndex ()
 Get sheet index.
 setSheetIndex ($pValue=0)
 Set sheet index.
 getGenerateSheetNavigationBlock ()
 Get sheet index.
 setGenerateSheetNavigationBlock ($pValue=true)
 Set sheet index.
 writeAllSheets ()
 Write all sheets (resets sheetIndex to NULL)
 generateHTMLHeader ($pIncludeStyles=false)
 Generate HTML header.
 generateSheetData ()
 Generate sheet data.
 generateNavigation ()
 Generate sheet tabs.
 generateStyles ($generateSurroundingHTML=true)
 Generate CSS styles.
 buildCSS ($generateSurroundingHTML=true)
 Build CSS styles.
 generateHTMLFooter ()
 Generate HTML footer.
 getPreCalculateFormulas ()
 Get Pre-Calculate Formulas.
 setPreCalculateFormulas ($pValue=true)
 Set Pre-Calculate Formulas.
 getImagesRoot ()
 Get images root.
 setImagesRoot ($pValue= '.')
 Set images root.
 getUseInlineCss ()
 Get use inline CSS?
 setUseInlineCss ($pValue=false)
 Set use inline CSS?
 formatColor ($pValue, $pFormat)
 Add color to formatted string as inline style.

Private Attributes

 $_tempDir = ''
 $_font = 'freesans'
 $_orientation = null
 $_paperSize = null

Static Private Attributes

static $_paperSizes

Additional Inherited Members

- Protected Attributes inherited from PHPExcel_Writer_HTML
 $_phpExcel
 $_isPdf = false

Detailed Description

Definition at line 40 of file PDF.php.

Constructor & Destructor Documentation

PHPExcel_Writer_PDF::__construct ( PHPExcel  $phpExcel)

Create a new PHPExcel_Writer_PDF.

Parameters
PHPExcel$phpExcelPHPExcel object

Reimplemented from PHPExcel_Writer_HTML.

Definition at line 150 of file PDF.php.

References PHPExcel_Writer_HTML\setUseInlineCss(), and PHPExcel_Shared_File\sys_get_temp_dir().

{
parent::__construct($phpExcel);
$this->setUseInlineCss(true);
}

+ Here is the call graph for this function:

Member Function Documentation

PHPExcel_Writer_PDF::getOrientation ( )

Get Orientation.

Returns
string

Definition at line 195 of file PDF.php.

References $_orientation.

{
}
PHPExcel_Writer_PDF::getPaperSize ( )

Get Paper Size.

Returns
int

Definition at line 175 of file PDF.php.

References $_paperSize.

{
}
PHPExcel_Writer_PDF::getTempDir ( )

Get temporary storage directory.

Returns
string

Definition at line 309 of file PDF.php.

References $_tempDir.

{
}
PHPExcel_Writer_PDF::save (   $pFilename = null)

Save PHPExcel to file.

Parameters
string$pFileName
Exceptions
Exception

Reimplemented from PHPExcel_Writer_HTML.

Definition at line 216 of file PDF.php.

References $_paperSize, PHPExcel_Writer_HTML\buildCSS(), PHPExcel_Writer_HTML\generateSheetData(), PHPExcel_Calculation\getArrayReturnType(), PHPExcel_Writer_HTML\getSheetIndex(), PHPExcel_Worksheet_PageSetup\ORIENTATION_LANDSCAPE, PHPExcel_Calculation\RETURN_ARRAY_AS_VALUE, and PHPExcel_Calculation\setArrayReturnType().

{
// garbage collect
$this->_phpExcel->garbageCollect();
$saveArrayReturnType = PHPExcel_Calculation::getArrayReturnType();
// Open file
$fileHandle = fopen($pFilename, 'w');
if ($fileHandle === false) {
throw new Exception("Could not open file $pFilename for writing.");
}
// Set PDF
$this->_isPdf = true;
// Build CSS
$this->buildCSS(true);
// Generate HTML
$html = '';
//$html .= $this->generateHTMLHeader(false);
$html .= $this->generateSheetData();
//$html .= $this->generateHTMLFooter();
// Default PDF paper size
$paperSize = 'LETTER'; // Letter (8.5 in. by 11 in.)
// Check for paper size and page orientation
if (is_null($this->getSheetIndex())) {
$orientation = ($this->_phpExcel->getSheet(0)->getPageSetup()->getOrientation() == PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE) ? 'L' : 'P';
$printPaperSize = $this->_phpExcel->getSheet(0)->getPageSetup()->getPaperSize();
$printMargins = $this->_phpExcel->getSheet(0)->getPageMargins();
} else {
$orientation = ($this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getOrientation() == PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE) ? 'L' : 'P';
$printPaperSize = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getPaperSize();
$printMargins = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageMargins();
}
// Override Page Orientation
if (!is_null($this->_orientation)) {
$orientation = ($this->_orientation == PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE) ? 'L' : 'P';
}
// Override Paper Size
if (!is_null($this->_paperSize)) {
$printPaperSize = $this->_paperSize;
}
if (isset(self::$_paperSizes[$printPaperSize])) {
$paperSize = self::$_paperSizes[$printPaperSize];
}
// Create PDF
$pdf = new TCPDF($orientation, 'pt', $paperSize);
$pdf->setFontSubsetting(false);
// Set margins, converting inches to points (using 72 dpi)
$pdf->SetMargins($printMargins->getLeft() * 72,$printMargins->getTop() * 72,$printMargins->getRight() * 72);
$pdf->SetAutoPageBreak(true,$printMargins->getBottom() * 72);
// $pdf->setHeaderMargin($printMargins->getHeader() * 72);
// $pdf->setFooterMargin($printMargins->getFooter() * 72);
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
$pdf->AddPage();
// Set the appropriate font
$pdf->SetFont($this->_font);
$pdf->writeHTML($html);
// Document info
$pdf->SetTitle($this->_phpExcel->getProperties()->getTitle());
$pdf->SetAuthor($this->_phpExcel->getProperties()->getCreator());
$pdf->SetSubject($this->_phpExcel->getProperties()->getSubject());
$pdf->SetKeywords($this->_phpExcel->getProperties()->getKeywords());
$pdf->SetCreator($this->_phpExcel->getProperties()->getCreator());
// Write to file
fwrite($fileHandle, $pdf->output($pFilename, 'S'));
// Close file
fclose($fileHandle);
}

+ Here is the call graph for this function:

PHPExcel_Writer_PDF::setFont (   $fontName)

Set font.

Examples: 'arialunicid0-chinese-simplified' 'arialunicid0-chinese-traditional' 'arialunicid0-korean' 'arialunicid0-japanese'

Parameters
string$fontName

Definition at line 165 of file PDF.php.

{
$this->_font = $fontName;
return $this;
}
PHPExcel_Writer_PDF::setOrientation (   $pValue = PHPExcel_Worksheet_PageSetup::ORIENTATION_DEFAULT)

Set Orientation.

Parameters
string$pValue
Returns
PHPExcel_Writer_PDF

Definition at line 205 of file PDF.php.

{
$this->_orientation = $pValue;
return $this;
}
PHPExcel_Writer_PDF::setPaperSize (   $pValue = PHPExcel_Worksheet_PageSetup::PAPERSIZE_LETTER)

Set Paper Size.

Parameters
int$pValue
Returns
PHPExcel_Writer_PDF

Definition at line 185 of file PDF.php.

{
$this->_paperSize = $pValue;
return $this;
}
PHPExcel_Writer_PDF::setTempDir (   $pValue = '')

Set temporary storage directory.

Parameters
string$pValueTemporary storage directory
Exceptions
ExceptionException when directory does not exist
Returns
PHPExcel_Writer_PDF

Definition at line 320 of file PDF.php.

{
if (is_dir($pValue)) {
$this->_tempDir = $pValue;
} else {
throw new Exception("Directory does not exist: $pValue");
}
return $this;
}

Field Documentation

PHPExcel_Writer_PDF::$_font = 'freesans'
private

Definition at line 53 of file PDF.php.

PHPExcel_Writer_PDF::$_orientation = null
private

Definition at line 60 of file PDF.php.

Referenced by getOrientation().

PHPExcel_Writer_PDF::$_paperSize = null
private

Definition at line 67 of file PDF.php.

Referenced by getPaperSize(), and save().

PHPExcel_Writer_PDF::$_paperSizes
staticprivate

Definition at line 75 of file PDF.php.

PHPExcel_Writer_PDF::$_tempDir = ''
private

Definition at line 46 of file PDF.php.

Referenced by getTempDir().


The documentation for this class was generated from the following file: