Skip to content

Commit ab4604c

Browse files
authored
Merge branch 'PHPOffice:master' into master
2 parents 967b0f6 + 3b12b4e commit ab4604c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1915
-57
lines changed

docs/changes/1.x/1.4.0.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,18 @@
1111
- Writer Word2007: Support for padding in Table Cell by [@Azamat8405](https://github.com/Azamat8405) in [#2697](https://github.com/PHPOffice/PHPWord/pull/2697)
1212
- Added support for PHP 8.4 by [@Progi1984](https://github.com/Progi1984) in [#2660](https://github.com/PHPOffice/PHPWord/pull/2660)
1313
- Autoload : Allow to use PHPWord without Composer fixing [#2543](https://github.com/PHPOffice/PHPWord/issues/2543), [#2552](https://github.com/PHPOffice/PHPWord/issues/2552), [#2716](https://github.com/PHPOffice/PHPWord/issues/2716), [#2717](https://github.com/PHPOffice/PHPWord/issues/2717) in [#2722](https://github.com/PHPOffice/PHPWord/pull/2722)
14+
- Add Default font color for Word by [@Collie-IT](https://github.com/Collie-IT) in [#2700](https://github.com/PHPOffice/PHPWord/pull/2700)
15+
- Writer HTML: Support Default font color by [@MichaelPFrey](https://github.com/MichaelPFrey)
16+
- Add basic ruby text (phonetic guide) support for Word2007 and HTML Reader/Writer, RTF Writer, basic support for ODT writing by [@Deadpikle](https://github.com/Deadpikle) in [#2727](https://github.com/PHPOffice/PHPWord/pull/2727)
1417

1518
### Bug fixes
1619

1720
- Writer ODText: Support for images inside a textRun by [@Progi1984](https://github.com/Progi1984) fixing [#2240](https://github.com/PHPOffice/PHPWord/issues/2240) in [#2668](https://github.com/PHPOffice/PHPWord/pull/2668)
1821
- Allow vAlign and vMerge on Style\Cell to be set to null by [@SpraxDev](https://github.com/SpraxDev) fixing [#2673](https://github.com/PHPOffice/PHPWord/issues/2673) in [#2676](https://github.com/PHPOffice/PHPWord/pull/2676)
1922
- Reader HTML: Support for differents size units for table by [@Progi1984](https://github.com/Progi1984) fixing [#2384](https://github.com/PHPOffice/PHPWord/issues/2384), [#2701](https://github.com/PHPOffice/PHPWord/issues/2701) in [#2725](https://github.com/PHPOffice/PHPWord/pull/2725)
20-
- Reader Word2007 : Respect paragraph indent units by [@tugmaks](https://github.com/tugmaks) & [@Progi1984](https://github.com/Progi1984) fixing [#507](https://github.com/PHPOffice/PHPWord/issues/507) in [#2726](https://github.com/PHPOffice/PHPWord/pull/2726)
21-
- Reader Word2007 : Support Header elements within Title elements by [@SpraxDev](https://github.com/SpraxDev) fixing [#2616](https://github.com/PHPOffice/PHPWord/issues/2616), [#2426](https://github.com/PHPOffice/PHPWord/issues/2426) in [#2674](https://github.com/PHPOffice/PHPWord/pull/2674)
23+
- Reader Word2007: Respect paragraph indent units by [@tugmaks](https://github.com/tugmaks) & [@Progi1984](https://github.com/Progi1984) fixing [#507](https://github.com/PHPOffice/PHPWord/issues/507) in [#2726](https://github.com/PHPOffice/PHPWord/pull/2726)
24+
- Reader Word2007: Support Header elements within Title elements by [@SpraxDev](https://github.com/SpraxDev) fixing [#2616](https://github.com/PHPOffice/PHPWord/issues/2616), [#2426](https://github.com/PHPOffice/PHPWord/issues/2426) in [#2674](https://github.com/PHPOffice/PHPWord/pull/2674)
25+
- Reader HTML: Support for inherit value for property line-height by [@Progi1984](https://github.com/Progi1984) fixing [#2683](https://github.com/PHPOffice/PHPWord/issues/2683) in [#2733](https://github.com/PHPOffice/PHPWord/pull/2733)
2226

2327
### Miscellaneous
2428

docs/usage/elements/ruby.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Ruby
2+
3+
Ruby (phonetic guide) text can be added by using the ``addRuby`` method. Ruby elements require a ``RubyProperties`` object, a ``TextRun`` for the base text, and a ``TextRun`` for the actual ruby (phonetic guide) text.
4+
5+
Here is one example for a complete ruby element setup:
6+
7+
``` php
8+
<?php
9+
$phpWord = new PhpWord();
10+
11+
$section = $phpWord->addSection();
12+
$properties = new RubyProperties();
13+
$properties->setAlignment(RubyProperties::ALIGNMENT_RIGHT_VERTICAL);
14+
$properties->setFontFaceSize(10);
15+
$properties->setFontPointsAboveBaseText(4);
16+
$properties->setFontSizeForBaseText(18);
17+
$properties->setLanguageId('ja-JP');
18+
19+
$baseTextRun = new TextRun(null);
20+
$baseTextRun->addText('私');
21+
$rubyTextRun = new TextRun(null);
22+
$rubyTextRun->addText('わたし');
23+
24+
$section->addRuby($baseTextRun, $rubyTextRun, $properties);
25+
```
26+
27+
- ``$baseTextRun``. ``TextRun`` to be used for the base text.
28+
- ``$rubyTextRun``. ``TextRun`` to be used for the ruby text.
29+
- ``$properties``. ``RubyProperties`` properties object for the ruby text.
30+
31+
A title with a phonetic guide is a little more complex, but still possible. Make sure you add the appropraite title style to your document.
32+
33+
```php
34+
$phpWord = new PhpWord();
35+
$fontStyle = new Font();
36+
$fontStyle->setAllCaps(true);
37+
$fontStyle->setBold(true);
38+
$fontStyle->setSize(24);
39+
$phpWord->addTitleStyle(1, ['name' => 'Arial', 'size' => 24, 'bold' => true, 'color' => '990000']);
40+
41+
$section = $phpWord->addSection();
42+
$properties = new RubyProperties();
43+
$properties->setAlignment(RubyProperties::ALIGNMENT_RIGHT_VERTICAL);
44+
$properties->setFontFaceSize(10);
45+
$properties->setFontPointsAboveBaseText(4);
46+
$properties->setFontSizeForBaseText(18);
47+
$properties->setLanguageId('ja-JP');
48+
49+
$baseTextRun = new TextRun(null);
50+
$baseTextRun->addText('私');
51+
$rubyTextRun = new TextRun(null);
52+
$rubyTextRun->addText('わたし');
53+
54+
$textRun = new TextRun();
55+
$textRun->addRuby($baseTextRun, $rubyTextRun, $properties);
56+
$section->addTitle($textRun, 1);
57+
```

docs/usage/introduction.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,14 @@ You can alter the default paper by using the following function:
127127

128128
### Default font
129129

130-
By default, every text appears in Arial 10 point. You can alter the
131-
default font by using the following two functions:
130+
By default, every text appears in Arial 10 point in the color black (000000).
131+
You can alter the default font by using the following functions:
132132

133133
``` php
134134
<?php
135135

136136
$phpWord->setDefaultFontName('Times New Roman');
137+
$phpWord->setDefaultFontColor('FF0000');
137138
$phpWord->setDefaultFontSize(12);
138139
```
139140

docs/usage/writers.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,13 @@ Settings::setPdfRendererName(Settings::PDF_RENDERER_MPDF);
110110
Settings::setPdfRendererPath(__DIR__ . '/../vendor/mpdf/mpdf');
111111
```
112112

113+
or you can edit settings in phpword.ini ( or phpword.ini.dist) file.
114+
115+
``` ini
116+
pdfRendererName = MPDF ;DomPDF, TCPDF, MPDF
117+
pdfRendererPath = /path/to/your/renderer/folder
118+
```
119+
113120
## RTF
114121
The name of the writer is `RTF`.
115122

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ nav:
6363
- OLE Object: 'usage/elements/oleobject.md'
6464
- Page Break: 'usage/elements/pagebreak.md'
6565
- Preserve Text: 'usage/elements/preservetext.md'
66+
- Ruby: 'usage/elements/ruby.md'
6667
- Text: 'usage/elements/text.md'
6768
- TextBox: 'usage/elements/textbox.md'
6869
- Text Break: 'usage/elements/textbreak.md'

phpstan-baseline.neon

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,11 @@ parameters:
430430
count: 1
431431
path: src/PhpWord/Shared/Html.php
432432

433+
-
434+
message: "#^Method PhpOffice\\\\PhpWord\\\\Shared\\\\Html\\:\\:parseRuby\\(\\) has no return type specified\\.$#"
435+
count: 1
436+
path: src/PhpWord/Shared/Html.php
437+
433438
-
434439
message: "#^Method PhpOffice\\\\PhpWord\\\\Shared\\\\Html\\:\\:parseStyleDeclarations\\(\\) has no return type specified\\.$#"
435440
count: 1
@@ -442,7 +447,7 @@ parameters:
442447

443448
-
444449
message: "#^Parameter \\#1 \\$attribute of static method PhpOffice\\\\PhpWord\\\\Shared\\\\Html\\:\\:parseStyle\\(\\) expects DOMAttr, DOMNode given\\.$#"
445-
count: 1
450+
count: 3
446451
path: src/PhpWord/Shared/Html.php
447452

448453
-
@@ -1051,14 +1056,14 @@ parameters:
10511056
path: src/PhpWord/Writer/ODText/Element/Table.php
10521057

10531058
-
1054-
message: "#^Method PhpOffice\\\\PhpWord\\\\Writer\\\\ODText\\\\Element\\\\Text\\:\\:replacetabs\\(\\) has parameter \\$text with no type specified\\.$#"
1059+
message: "#^Method PhpOffice\\\\PhpWord\\\\Writer\\\\ODText\\\\Element\\\\AbstractElement\\:\\:replaceTabs\\(\\) has parameter \\$text with no type specified\\.$#"
10551060
count: 1
1056-
path: src/PhpWord/Writer/ODText/Element/Text.php
1061+
path: src/PhpWord/Writer/ODText/Element/AbstractElement.php
10571062

10581063
-
1059-
message: "#^Method PhpOffice\\\\PhpWord\\\\Writer\\\\ODText\\\\Element\\\\Text\\:\\:replacetabs\\(\\) has parameter \\$xmlWriter with no type specified\\.$#"
1064+
message: "#^Method PhpOffice\\\\PhpWord\\\\Writer\\\\ODText\\\\Element\\\\AbstractElement\\:\\:replaceTabs\\(\\) has parameter \\$xmlWriter with no type specified\\.$#"
10601065
count: 1
1061-
path: src/PhpWord/Writer/ODText/Element/Text.php
1066+
path: src/PhpWord/Writer/ODText/Element/AbstractElement.php
10621067

10631068
-
10641069
message: "#^Method PhpOffice\\\\PhpWord\\\\Writer\\\\ODText\\\\Element\\\\Text\\:\\:writeChangeInsertion\\(\\) has parameter \\$start with no type specified\\.$#"
@@ -1689,6 +1694,11 @@ parameters:
16891694
message: "#^Cannot access property \\$length on DOMNodeList\\<DOMNode\\>\\|false\\.$#"
16901695
count: 9
16911696
path: tests/PhpWordTests/Writer/HTML/ElementTest.php
1697+
1698+
-
1699+
message: "#^Cannot access property \\$length on DOMNodeList\\<DOMNode\\>\\|false\\.$#"
1700+
count: 2
1701+
path: tests/PhpWordTests/Writer/HTML/Element/RubyTest.php
16921702

16931703
-
16941704
message: "#^Cannot call method item\\(\\) on DOMNodeList\\<DOMNode\\>\\|false\\.$#"

phpword.ini.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ outputEscapingEnabled = false
1414

1515
defaultFontName = Arial
1616
defaultFontSize = 10
17+
defaultFontColor = 000000
1718

1819
[Paper]
1920

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?php
2+
3+
use PhpOffice\PhpWord\ComplexType\RubyProperties;
4+
use PhpOffice\PhpWord\Element\TextRun;
5+
6+
include_once 'Sample_Header.php';
7+
8+
// New Word Document
9+
echo date('H:i:s'), ' Create sample for Ruby (Phonetic Guide) use', EOL;
10+
$phpWord = new PhpOffice\PhpWord\PhpWord();
11+
12+
// Section for demonstrating ruby (phonetic guide) features
13+
$section = $phpWord->addSection();
14+
15+
$section->addText('Here is some normal text with no ruby, also known as "phonetic guide", text.');
16+
17+
$properties = new RubyProperties();
18+
$properties->setAlignment(RubyProperties::ALIGNMENT_CENTER);
19+
$properties->setFontFaceSize(10);
20+
$properties->setFontPointsAboveBaseText(20);
21+
$properties->setFontSizeForBaseText(18);
22+
$properties->setLanguageId('en-US');
23+
24+
$textRun = $section->addTextRun();
25+
$textRun->addText('Here is a demonstration of ruby text for ');
26+
$baseTextRun = new TextRun(null);
27+
$baseTextRun->addText('this');
28+
$rubyTextRun = new TextRun(null);
29+
$rubyTextRun->addText('ruby-text');
30+
$textRun->addRuby($baseTextRun, $rubyTextRun, $properties);
31+
$textRun->addText(' word.');
32+
33+
$textRun = $section->addTextRun();
34+
$properties = new RubyProperties();
35+
$properties->setAlignment(RubyProperties::ALIGNMENT_CENTER);
36+
$properties->setFontFaceSize(10);
37+
$properties->setFontPointsAboveBaseText(20);
38+
$properties->setFontSizeForBaseText(18);
39+
$properties->setLanguageId('ja-JP');
40+
$textRun->addText('Here is a demonstration of ruby text for Japanese text: ');
41+
$baseTextRun = new TextRun(null);
42+
$baseTextRun->addText('');
43+
$rubyTextRun = new TextRun(null);
44+
$rubyTextRun->addText('わたし');
45+
$textRun->addRuby($baseTextRun, $rubyTextRun, $properties);
46+
47+
$section->addText('You can also have ruby text for titles:');
48+
49+
$phpWord->addTitleStyle(1, ['name' => 'Arial', 'size' => 24, 'bold' => true, 'color' => '000099']);
50+
51+
$properties = new RubyProperties();
52+
$properties->setAlignment(RubyProperties::ALIGNMENT_CENTER);
53+
$properties->setFontFaceSize(10);
54+
$properties->setFontPointsAboveBaseText(50);
55+
$properties->setFontSizeForBaseText(18);
56+
$properties->setLanguageId('ja-JP');
57+
58+
$baseTextRun = new TextRun(null);
59+
$baseTextRun->addText('');
60+
$rubyTextRun = new TextRun(null);
61+
$rubyTextRun->addText('わたし');
62+
$textRun = new TextRun();
63+
$textRun->addRuby($baseTextRun, $rubyTextRun, $properties);
64+
$section->addTitle($textRun, 1);
65+
66+
// Save file
67+
echo write($phpWord, basename(__FILE__, '.php'), $writers);
68+
if (!CLI) {
69+
include_once 'Sample_Footer.php';
70+
}

0 commit comments

Comments
 (0)