Merge pull request #356 from GMTA/develop
This commit is contained in:
parent
fa7f2cdc25
commit
41983e01f3
10
README.md
10
README.md
|
|
@ -112,7 +112,7 @@ $section->addText(
|
|||
* - using explicitly created font style object.
|
||||
*/
|
||||
|
||||
// Adding Text element having font customized inline...
|
||||
// Adding Text element with font customized inline...
|
||||
$section->addText(
|
||||
htmlspecialchars(
|
||||
'"Great achievement is usually born of great sacrifice, '
|
||||
|
|
@ -122,7 +122,7 @@ $section->addText(
|
|||
array('name' => 'Tahoma', 'size' => 10)
|
||||
);
|
||||
|
||||
// Adding Text element having font customized using named font style...
|
||||
// Adding Text element with font customized using named font style...
|
||||
$fontStyleName = 'oneUserDefinedStyle';
|
||||
$phpWord->addFontStyle(
|
||||
$fontStyleName,
|
||||
|
|
@ -137,7 +137,7 @@ $section->addText(
|
|||
$fontStyleName
|
||||
);
|
||||
|
||||
// Adding Text element having font customized using explicitly created font style object...
|
||||
// Adding Text element with font customized using explicitly created font style object...
|
||||
$fontStyle = new \PhpOffice\PhpWord\Style\Font();
|
||||
$fontStyle->setBold(true);
|
||||
$fontStyle->setName('Tahoma');
|
||||
|
|
@ -159,8 +159,8 @@ $objWriter->save('helloWorld.odt');
|
|||
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'HTML');
|
||||
$objWriter->save('helloWorld.html');
|
||||
|
||||
/* Note: RTF was skipped, because it's not XML-based and requires a different example. */
|
||||
/* Note: PDF was skipped, because we use "HTML-to-PDF" approach to create PDF documents. */
|
||||
/* Note: we skip RTF, because it's not XML-based and requires a different example. */
|
||||
/* Note: we skip PDF, because "HTML-to-PDF" approach is used to create PDF documents. */
|
||||
```
|
||||
:warning: Escape any string you pass to OOXML/ODF/HTML document, otherwise it may get broken.
|
||||
|
||||
|
|
|
|||
|
|
@ -25,36 +25,53 @@ folder <https://github.com/PHPOffice/PHPWord/tree/master/samples/>`__.
|
|||
$section = $phpWord->addSection();
|
||||
// Adding Text element to the Section having font styled by default...
|
||||
$section->addText(
|
||||
htmlspecialchars('"Learn from yesterday, live for today, hope for tomorrow. The important thing is not to stop questioning." (Albert Einstein)')
|
||||
htmlspecialchars(
|
||||
'"Learn from yesterday, live for today, hope for tomorrow. '
|
||||
. 'The important thing is not to stop questioning." '
|
||||
. '(Albert Einstein)'
|
||||
)
|
||||
);
|
||||
|
||||
/*
|
||||
* Note: it is possible to customize font style of the Text element you add in three ways:
|
||||
* Note: it's possible to customize font style of the Text element you add in three ways:
|
||||
* - inline;
|
||||
* - using named font style (new font style object will be implicitly created);
|
||||
* - using explicitly created font style object.
|
||||
*/
|
||||
|
||||
// Adding Text element having font customized inline...
|
||||
// Adding Text element with font customized inline...
|
||||
$section->addText(
|
||||
htmlspecialchars('"Great achievement is usually born of great sacrifice, and is never the result of selfishness." (Napoleon Hill)'),
|
||||
htmlspecialchars(
|
||||
'"Great achievement is usually born of great sacrifice, '
|
||||
. 'and is never the result of selfishness." '
|
||||
. '(Napoleon Hill)'
|
||||
),
|
||||
array('name' => 'Tahoma', 'size' => 10)
|
||||
);
|
||||
|
||||
// Adding Text element having font customized using named font style...
|
||||
// Adding Text element with font customized using named font style...
|
||||
$fontStyleName = 'oneUserDefinedStyle';
|
||||
$phpWord->addFontStyle($fontStyleName, array('name' => 'Tahoma', 'size' => 10, 'color' => '1B2232', 'bold' => true));
|
||||
$phpWord->addFontStyle(
|
||||
$fontStyleName,
|
||||
array('name' => 'Tahoma', 'size' => 10, 'color' => '1B2232', 'bold' => true)
|
||||
);
|
||||
$section->addText(
|
||||
htmlspecialchars('"The greatest accomplishment is not in never falling, but in rising again after you fall." (Vince Lombardi)'),
|
||||
htmlspecialchars(
|
||||
'"The greatest accomplishment is not in never falling, '
|
||||
. 'but in rising again after you fall." '
|
||||
. '(Vince Lombardi)'
|
||||
),
|
||||
$fontStyleName
|
||||
);
|
||||
|
||||
// Adding Text element having font customized using explicitly created font style object...
|
||||
// Adding Text element with font customized using explicitly created font style object...
|
||||
$fontStyle = new \PhpOffice\PhpWord\Style\Font();
|
||||
$fontStyle->setBold(true);
|
||||
$fontStyle->setName('Tahoma');
|
||||
$fontStyle->setSize(13);
|
||||
$myTextElement = $section->addText(htmlspecialchars('"Believe you can and you\'re halfway there." (Theodor Roosevelt)'));
|
||||
$myTextElement = $section->addText(
|
||||
htmlspecialchars('"Believe you can and you\'re halfway there." (Theodor Roosevelt)')
|
||||
);
|
||||
$myTextElement->setFontStyle($fontStyle);
|
||||
|
||||
// Saving the document as OOXML file...
|
||||
|
|
@ -69,8 +86,8 @@ folder <https://github.com/PHPOffice/PHPWord/tree/master/samples/>`__.
|
|||
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'HTML');
|
||||
$objWriter->save('helloWorld.html');
|
||||
|
||||
/* Note: RTF was skipped here, because the format is not XML-based and requires a bit different example. */
|
||||
/* Note: PDF was skipped here, because we use "HTML-to-PDF" approach to create PDF documents. */
|
||||
/* Note: we skip RTF, because it's not XML-based and requires a different example. */
|
||||
/* Note: we skip PDF, because "HTML-to-PDF" approach is used to create PDF documents. */
|
||||
|
||||
Settings
|
||||
--------
|
||||
|
|
|
|||
|
|
@ -225,36 +225,53 @@ $phpWord = new \PhpOffice\PhpWord\PhpWord();
|
|||
$section = $phpWord->addSection();
|
||||
// Adding Text element to the Section having font styled by default...
|
||||
$section->addText(
|
||||
htmlspecialchars('"Learn from yesterday, live for today, hope for tomorrow. The important thing is not to stop questioning." (Albert Einstein)')
|
||||
htmlspecialchars(
|
||||
'"Learn from yesterday, live for today, hope for tomorrow. '
|
||||
. 'The important thing is not to stop questioning." '
|
||||
. '(Albert Einstein)'
|
||||
)
|
||||
);
|
||||
|
||||
/*
|
||||
* Note: it is possible to customize font style of the Text element you add in three ways:
|
||||
* Note: it's possible to customize font style of the Text element you add in three ways:
|
||||
* - inline;
|
||||
* - using named font style (new font style object will be implicitly created);
|
||||
* - using explicitly created font style object.
|
||||
*/
|
||||
|
||||
// Adding Text element having font customized inline...
|
||||
// Adding Text element with font customized inline...
|
||||
$section->addText(
|
||||
htmlspecialchars('"Great achievement is usually born of great sacrifice, and is never the result of selfishness." (Napoleon Hill)'),
|
||||
htmlspecialchars(
|
||||
'"Great achievement is usually born of great sacrifice, '
|
||||
. 'and is never the result of selfishness." '
|
||||
. '(Napoleon Hill)'
|
||||
),
|
||||
array('name' => 'Tahoma', 'size' => 10)
|
||||
);
|
||||
|
||||
// Adding Text element having font customized using named font style...
|
||||
// Adding Text element with font customized using named font style...
|
||||
$fontStyleName = 'oneUserDefinedStyle';
|
||||
$phpWord->addFontStyle($fontStyleName, array('name' => 'Tahoma', 'size' => 10, 'color' => '1B2232', 'bold' => true));
|
||||
$phpWord->addFontStyle(
|
||||
$fontStyleName,
|
||||
array('name' => 'Tahoma', 'size' => 10, 'color' => '1B2232', 'bold' => true)
|
||||
);
|
||||
$section->addText(
|
||||
htmlspecialchars('"The greatest accomplishment is not in never falling, but in rising again after you fall." (Vince Lombardi)'),
|
||||
htmlspecialchars(
|
||||
'"The greatest accomplishment is not in never falling, '
|
||||
. 'but in rising again after you fall." '
|
||||
. '(Vince Lombardi)'
|
||||
),
|
||||
$fontStyleName
|
||||
);
|
||||
|
||||
// Adding Text element having font customized using explicitly created font style object...
|
||||
// Adding Text element with font customized using explicitly created font style object...
|
||||
$fontStyle = new \PhpOffice\PhpWord\Style\Font();
|
||||
$fontStyle->setBold(true);
|
||||
$fontStyle->setName('Tahoma');
|
||||
$fontStyle->setSize(13);
|
||||
$myTextElement = $section->addText(htmlspecialchars('"Believe you can and you\'re halfway there." (Theodor Roosevelt)'));
|
||||
$myTextElement = $section->addText(
|
||||
htmlspecialchars('"Believe you can and you\'re halfway there." (Theodor Roosevelt)')
|
||||
);
|
||||
$myTextElement->setFontStyle($fontStyle);
|
||||
|
||||
// Saving the document as OOXML file...
|
||||
|
|
@ -269,8 +286,8 @@ $objWriter->save('helloWorld.odt');
|
|||
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'HTML');
|
||||
$objWriter->save('helloWorld.html');
|
||||
|
||||
/* Note: RTF was skipped here, because the format is not XML-based and requires a bit different example. */
|
||||
/* Note: PDF was skipped here, because we use "HTML-to-PDF" approach to create PDF documents. */
|
||||
/* Note: we skip RTF, because it's not XML-based and requires a different example. */
|
||||
/* Note: we skip PDF, because "HTML-to-PDF" approach is used to create PDF documents. */
|
||||
```
|
||||
|
||||
## Settings
|
||||
|
|
|
|||
Loading…
Reference in New Issue