Skip to content

Commit e0e98dd

Browse files
authored
Merge branch 'master' into wordunimplemented2
2 parents cf1fd2a + 761280b commit e0e98dd

File tree

11 files changed

+173
-82
lines changed

11 files changed

+173
-82
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: 🐛 Bug Report
2+
description: Create a report to help improve PHPWord
3+
labels: [ "Bug Report" ]
4+
body:
5+
- type: markdown
6+
attributes:
7+
value: |
8+
### ❗️ Read this before submitting your bug report:
9+
- **Write in English/French.** Reports in all other languages will be closed.
10+
- **Provide as much detail as possible**
11+
- Attachments : Error logs, Screenshots, Document files (generated and expected).
12+
- If the issue cannot be reproduced, it cannot be fixed.
13+
- type: textarea
14+
id: what-happened
15+
attributes:
16+
label: Describe the bug and add attachments
17+
description: What went wrong? If possible, add screenshots, error logs, document files (generated and expected) or screen recordings to help explain your problem.
18+
validations:
19+
required: true
20+
- type: textarea
21+
id: expected-behavior
22+
attributes:
23+
label: Expected behavior
24+
description: A clear and concise description of what you expected to happen.
25+
validations:
26+
required: true
27+
- type: textarea
28+
id: steps-reproduce
29+
attributes:
30+
label: Steps to reproduce
31+
description: Please provide a code sample that reproduces the issue.
32+
placeholder: |
33+
```php
34+
<?php
35+
require __DIR__ . '/vendor/autoload.php';
36+
37+
$phpWord = new \PhpOffice\PhpWord\PhpWord();
38+
$section = $phpWord->addSection();
39+
$section->...
40+
```
41+
validations:
42+
required: true
43+
- type: input
44+
id: phpword-version
45+
attributes:
46+
label: PHPWord version(s) where the bug happened
47+
placeholder: "e.g., 1.2.0 or master"
48+
validations:
49+
required: true
50+
- type: input
51+
id: php-version
52+
attributes:
53+
label: PHP version(s) where the bug happened
54+
placeholder: "e.g., 7.1 or 8.2"
55+
validations:
56+
required: true
57+
- type: checkboxes
58+
attributes:
59+
label: Priority
60+
description: Funded tickets have a higher priority.
61+
options:
62+
- label: I want to crowdfund the bug fix (with [@algora-io](https://docs.algora.io/bounties/overview)) and fund a community developer.
63+
required: false
64+
- label: I want to pay the bug fix and fund a maintainer for that. (Contact @Progi1984)
65+
required: false
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: 💡 Feature request
2+
description: Suggest an idea for this project
3+
labels: [ "Change Request" ]
4+
body:
5+
- type: markdown
6+
attributes:
7+
value: |
8+
### ❗️ Read this before submitting your bug report:
9+
- **Write in English/French.** Reports in all other languages will be closed.
10+
- **Provide as much detail as possible**
11+
- Attachments : Error logs, Screenshots, Document files (generated and expected).
12+
- If the issue cannot be reproduced, it cannot be fixed.
13+
- type: textarea
14+
id: problem
15+
attributes:
16+
label: Describe the problem
17+
description: A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
18+
validations:
19+
required: true
20+
- type: textarea
21+
id: expected-behavior
22+
attributes:
23+
label: Describe the expected behavior
24+
description: A clear and concise description of what you expected to happen. If possible, add screenshots, document files (expected).
25+
validations:
26+
required: true
27+
- type: checkboxes
28+
attributes:
29+
label: Priority
30+
description: Funded tickets have a higher priority.
31+
options:
32+
- label: I want to crowdfund the feature (with [@algora-io](https://docs.algora.io/bounties/overview)) and fund a community developer.
33+
required: false
34+
- label: I want to pay the feature and fund a maintainer for that. (Contact @Progi1984)
35+
required: false

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 0 additions & 38 deletions
This file was deleted.

.github/ISSUE_TEMPLATE/feature_request.md

Lines changed: 0 additions & 22 deletions
This file was deleted.

.github/ISSUE_TEMPLATE/how-to-use.md

Lines changed: 0 additions & 14 deletions
This file was deleted.

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Fixes # (issue)
66

77
### Checklist:
88

9-
- [ ] I have run `composer run-script check --timeout=0` and no errors were reported
10-
- [ ] The new code is covered by unit tests (check build/coverage for coverage report)
11-
- [ ] I have updated the documentation to describe the changes
9+
- [ ] My CI is :green_circle:
10+
- [ ] I have covered by unit tests my new code (check build/coverage for coverage report)
11+
- [ ] I have updated the [documentation](https://github.com/PHPOffice/PHPWord/tree/master/docs) to describe the changes
12+
- [ ] I have updated the [changelog](https://github.com/PHPOffice/PHPWord/blob/master/docs/changes/2.x/2.0.0.md)

docs/changes/2.x/2.0.0.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,19 @@
55
## Enhancements
66

77
- IOFactory : Added extractVariables method to extract variables from a document [@sibalonat](https://github.com/sibalonat) in [#2515](https://github.com/PHPOffice/PHPWord/pull/2515)
8+
- PDF Writer : Documented how to specify a PDF renderer, when working with the PDF writer, as well as the three available choices by [@settermjd](https://github.com/settermjd) in [#2642](https://github.com/PHPOffice/PHPWord/pull/2642)
89

910
### Bug fixes
1011

1112
- MsDoc Reader : Correct Font Size Calculation by [@oleibman](https://github.com/oleibman) fixing [#2526](https://github.com/PHPOffice/PHPWord/issues/2526) in [#2531](https://github.com/PHPOffice/PHPWord/pull/2531)
13+
- Html Reader : Process Titles as Headings not Paragraphs [@0b10011](https://github.com/0b10011) and [@oleibman](https://github.com/oleibman) Issue [#1692](https://github.com/PHPOffice/PHPWord/issues/1692) PR [#2533](https://github.com/PHPOffice/PHPWord/pull/2533)
14+
- Generate Table Cell if Row Doesn't Have Any [@oleibman](https://github.com/oleibman) fixing [#2505](https://github.com/PHPOffice/PHPWord/issues/2505) in [#2516](https://github.com/PHPOffice/PHPWord/pull/2516)
1215
- TemplateProcessor Persist File After Destruct [@oleibman](https://github.com/oleibman) fixing [#2539](https://github.com/PHPOffice/PHPWord/issues/2539) in [#2545](https://github.com/PHPOffice/PHPWord/pull/2545)
16+
- TemplateProcessor Destructor Problem with Php7 [@oleibman](https://github.com/oleibman) fixing [#2548](https://github.com/PHPOffice/PHPWord/issues/2548) in [#2554](https://github.com/PHPOffice/PHPWord/pull/2554)
1317
- bug: TemplateProcessor fix multiline values [@gimler](https://github.com/gimler) fixing [#268](https://github.com/PHPOffice/PHPWord/issues/268), [#2323](https://github.com/PHPOffice/PHPWord/issues/2323) and [#2486](https://github.com/PHPOffice/PHPWord/issues/2486) in [#2522](https://github.com/PHPOffice/PHPWord/pull/2522)
14-
1518
- 32-bit Problem in PasswordEncoder [@oleibman](https://github.com/oleibman) fixing [#2550](https://github.com/PHPOffice/PHPWord/issues/2550) in [#2551](https://github.com/PHPOffice/PHPWord/pull/2551)
19+
- Typo : Fix hardcoded macro chars in TemplateProcessor method [@glafarge](https://github.com/glafarge) in [#2618](https://github.com/PHPOffice/PHPWord/pull/2618)
20+
- XML Reader : Prevent fatal errors when opening corrupt files or "doc" files [@mmcev106](https://github.com/mmcev106) in [#2626](https://github.com/PHPOffice/PHPWord/pull/2626)
1621

1722
### Miscellaneous
1823

@@ -22,6 +27,7 @@
2227
- Bump phpmd/phpmd from 2.14.1 to 2.15.0 by [@dependabot](https://github.com/dependabot) in [#2538](https://github.com/PHPOffice/PHPWord/pull/2538)
2328
- Bump phpunit/phpunit from 9.6.14 to 9.6.15 by [@dependabot](https://github.com/dependabot) in [#2537](https://github.com/PHPOffice/PHPWord/pull/2537)
2429
- Bump symfony/process from 5.4.28 to 5.4.34 by [@dependabot](https://github.com/dependabot) in [#2536](https://github.com/PHPOffice/PHPWord/pull/2536)
25-
- Allow rgb() when converting Html [@oleibman](https://github.com/oleibman) fixing [#2508](https://github.com/PHPOffice/PHPWord/issues/2508) in [#2512](https://github.com/PHPOffice/PHPWord/pull/2512)
30+
- Allow rgb() when converting Html by [@oleibman](https://github.com/oleibman) fixing [#2508](https://github.com/PHPOffice/PHPWord/issues/2508) in [#2512](https://github.com/PHPOffice/PHPWord/pull/2512)
31+
- Improved Issue Template by [@Progi1984](https://github.com/Progi1984) in [#2609](https://github.com/PHPOffice/PHPWord/pull/2609)
2632

2733
### BC Breaks

docs/usage/writers.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,29 @@ $writer = IOFactory::createWriter($oPhpWord, 'PDF');
8787
$writer->save(__DIR__ . '/sample.pdf');
8888
```
8989

90+
#### Specify the PDF Renderer
91+
92+
Before PHPWord can write a PDF, you **must** specify the renderer to use and the path to it.
93+
Currently, three renderers are supported:
94+
95+
- [DomPDF](https://github.com/dompdf/dompdf)
96+
- [MPDF](https://mpdf.github.io/)
97+
- [TCPDF](https://tcpdf.org/)
98+
99+
To specify the renderer you use two static `Settings` functions:
100+
101+
- `setPdfRendererName`: This sets the name of the renderer library to use.
102+
Provide one of [`Settings`' three `PDF_` constants](https://github.com/PHPOffice/PHPWord/blob/master/src/PhpWord/Settings.php#L39-L41) to the function call.
103+
- `setPdfRendererPath`: This sets the path to the renderer library.
104+
This directory is the renderer's package directory within Composer's _vendor_ directory.
105+
106+
In the code below, you can see an example of setting MPDF as the desired PDF renderer.
107+
108+
```php
109+
Settings::setPdfRendererName(Settings::PDF_RENDERER_MPDF);
110+
Settings::setPdfRendererPath(__DIR__ . '/../vendor/mpdf/mpdf');
111+
```
112+
90113
## RTF
91114
The name of the writer is `RTF`.
92115

src/PhpWord/Shared/XMLReader.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,15 @@ public function getDomFromZip($zipFile, $xmlFile)
6161
}
6262

6363
$zip = new ZipArchive();
64-
$zip->open($zipFile);
64+
$openStatus = $zip->open($zipFile);
65+
if ($openStatus !== true) {
66+
/**
67+
* Throw an exception since making further calls on the ZipArchive would cause a fatal error.
68+
* This prevents fatal errors on corrupt archives and attempts to open old "doc" files.
69+
*/
70+
throw new Exception("The archive failed to load with the following error code: $openStatus");
71+
}
72+
6573
$content = $zip->getFromName(ltrim($xmlFile, '/'));
6674
$zip->close();
6775

src/PhpWord/TemplateProcessor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -815,8 +815,8 @@ public function cloneRow($search, $numberOfClones): void
815815
*/
816816
public function deleteRow(string $search): void
817817
{
818-
if ('${' !== substr($search, 0, 2) && '}' !== substr($search, -1)) {
819-
$search = '${' . $search . '}';
818+
if (self::$macroOpeningChars !== substr($search, 0, 2) && self::$macroClosingChars !== substr($search, -1)) {
819+
$search = self::$macroOpeningChars . $search . self::$macroClosingChars;
820820
}
821821

822822
$tagPos = strpos($this->tempDocumentMainPart, $search);

0 commit comments

Comments
 (0)