#275: Recipe for adding a link within a title
This commit is contained in:
parent
f54d9a1eb4
commit
e9f8e889f8
|
|
@ -65,3 +65,25 @@ Define a numbering style and title styles, and match the two styles (with ``pSty
|
||||||
$section->addTitle('Heading 1', 1);
|
$section->addTitle('Heading 1', 1);
|
||||||
$section->addTitle('Heading 2', 2);
|
$section->addTitle('Heading 2', 2);
|
||||||
$section->addTitle('Heading 3', 3);
|
$section->addTitle('Heading 3', 3);
|
||||||
|
|
||||||
|
Add a link within a title
|
||||||
|
-------------------------
|
||||||
|
|
||||||
|
Apply 'HeadingN' paragraph style to TextRun or Link. Sample code:
|
||||||
|
|
||||||
|
.. code-block:: php
|
||||||
|
|
||||||
|
$phpWord = new \PhpOffice\PhpWord\PhpWord();
|
||||||
|
$phpWord->addTitleStyle(1, array('size' => 16, 'bold' => true));
|
||||||
|
$phpWord->addTitleStyle(2, array('size' => 14, 'bold' => true));
|
||||||
|
$phpWord->addFontStyle('Link', array('color' => '0000FF', 'underline' => 'single'));
|
||||||
|
|
||||||
|
$section = $phpWord->addSection();
|
||||||
|
|
||||||
|
// Textrun
|
||||||
|
$textrun = $section->addTextRun('Heading1');
|
||||||
|
$textrun->addText('The ');
|
||||||
|
$textrun->addLink('https://github.com/PHPOffice/PHPWord', 'PHPWord', 'Link');
|
||||||
|
|
||||||
|
// Link
|
||||||
|
$section->addLink('https://github.com/', 'GitHub', 'Link', 'Heading2');
|
||||||
|
|
|
||||||
|
|
@ -1017,6 +1017,27 @@ $section->addTitle('Heading 2', 2);
|
||||||
$section->addTitle('Heading 3', 3);
|
$section->addTitle('Heading 3', 3);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Add a link within a title
|
||||||
|
|
||||||
|
Apply 'HeadingN' paragraph style to TextRun or Link. Sample code:
|
||||||
|
|
||||||
|
```php
|
||||||
|
$phpWord = new \PhpOffice\PhpWord\PhpWord();
|
||||||
|
$phpWord->addTitleStyle(1, array('size' => 16, 'bold' => true));
|
||||||
|
$phpWord->addTitleStyle(2, array('size' => 14, 'bold' => true));
|
||||||
|
$phpWord->addFontStyle('Link', array('color' => '0000FF', 'underline' => 'single'));
|
||||||
|
|
||||||
|
$section = $phpWord->addSection();
|
||||||
|
|
||||||
|
// Textrun
|
||||||
|
$textrun = $section->addTextRun('Heading1');
|
||||||
|
$textrun->addText('The ');
|
||||||
|
$textrun->addLink('https://github.com/PHPOffice/PHPWord', 'PHPWord', 'Link');
|
||||||
|
|
||||||
|
// Link
|
||||||
|
$section->addLink('https://github.com/', 'GitHub', 'Link', 'Heading2');
|
||||||
|
```
|
||||||
|
|
||||||
# Frequently asked questions
|
# Frequently asked questions
|
||||||
|
|
||||||
## Is this the same with PHPWord that I found in CodePlex?
|
## Is this the same with PHPWord that I found in CodePlex?
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue