Skip to content

Commit 898be23

Browse files
committed
Merge pull request #205 from ivanlanin/develop
Add DomPDF to composer.json and enable archive image source
2 parents 6eb2c66 + 52b3506 commit 898be23

20 files changed

+766
-379
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ before_script:
1818
## Composer
1919
# - curl -s http://getcomposer.org/installer | php
2020
# - php composer.phar install --prefer-source
21+
- composer self-update
22+
- composer require dompdf/dompdf:0.6.*
2123
- composer install --prefer-source
22-
- composer selfupdate --quiet
2324
## PHP_CodeSniffer
2425
- pyrus install pear/PHP_CodeSniffer
2526
- phpenv rehash

CHANGELOG.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ This release marked heavy refactorings on internal code structure with the creat
2727
- Object: Ability to add object in header, footer, textrun, and footnote - @ivanlanin GH-187
2828
- Media: Add `Media::resetElements()` to reset all media data - @juzi GH-19
2929
- General: Add `Style::resetStyles()`, `Footnote::resetElements()`, and `TOC::resetTitles()` - @ivanlanin GH-187
30-
- Reader: Ability to read header, footer, footnotes, link, preservetext, textbreak, pagebreak, table, and list - @ivanlanin
30+
- DOCX Reader: Ability to read header, footer, footnotes, link, preservetext, textbreak, pagebreak, table, list, image - @ivanlanin
3131
- Endnote: Ability to add endnotes - @ivanlanin
3232
- ListItem: Ability to create custom list and reset list number - @ivanlanin GH-10 GH-198
3333
- ODT Writer: Basic table writing support - @ivanlanin
3434
- Image: Keep image aspect ratio if only 1 dimension styled - @japonicus GH-194
35-
- HTML Writer: Basic HTML writer initiated - @ivanlanin GH-203 GH-67 GH-147
36-
- PDF Writer: Basic PDF writer initiated using DomPDF - @ivanlanin GH-68
35+
- HTML Writer: Basic HTML writer: text, textrun, link, title, textbreak, table, image (as Base64), footnote, endnote - @ivanlanin GH-203 GH-67 GH-147
36+
- PDF Writer: Basic PDF writer using DomPDF: All HTML element except image - @ivanlanin GH-68
3737

3838
### Bugfixes
3939

composer.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,10 @@
4040
"phpunit/phpunit": "3.7.*"
4141
},
4242
"suggest": {
43-
"ext-gd2": "*",
44-
"ext-xmlwriter": "*",
45-
"ext-xsl": "*"
43+
"ext-gd2": "Required to add images",
44+
"ext-xmlwriter": "Required to write DOCX and ODT",
45+
"ext-xsl": "Required to apply XSL style sheet to template part",
46+
"dompdf/dompdf": "Required to write PDF"
4647
},
4748
"autoload": {
4849
"psr-4": {

docs/intro.rst

Lines changed: 57 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -62,63 +62,63 @@ Below are the supported features for each file formats.
6262
Writers
6363
~~~~~~~
6464

65-
+-------------------------------------------------+--------+-------+-------+
66-
| Features | DOCX | ODT | RTF |
67-
+=========================+=======================+========+=======+=======+
68-
| **Document Properties** | Standard | | | |
69-
+ +-----------------------+--------+-------+-------+
70-
| | Extended | | | |
71-
+ +-----------------------+--------+-------+-------+
72-
| | UserDefined | | | |
73-
+-------------------------+-----------------------+--------+-------+-------+
74-
| **Element Type** | Text ||||
75-
+ +-----------------------+--------+-------+-------+
76-
| | Text Run ||||
77-
+ +-----------------------+--------+-------+-------+
78-
| | Title || | |
79-
+ +-----------------------+--------+-------+-------+
80-
| | Link || | |
81-
+ +-----------------------+--------+-------+-------+
82-
| | Preserve Text || | |
83-
+ +-----------------------+--------+-------+-------+
84-
| | Text Break ||||
85-
+ +-----------------------+--------+-------+-------+
86-
| | Page Break || | |
87-
+ +-----------------------+--------+-------+-------+
88-
| | List || | |
89-
+ +-----------------------+--------+-------+-------+
90-
| | Table || | |
91-
+ +-----------------------+--------+-------+-------+
92-
| | Image || | |
93-
+ +-----------------------+--------+-------+-------+
94-
| | Object || | |
95-
+ +-----------------------+--------+-------+-------+
96-
| | Watermark || | |
97-
+ +-----------------------+--------+-------+-------+
98-
| | Table of Contents || | |
99-
+ +-----------------------+--------+-------+-------+
100-
| | Header || | |
101-
+ +-----------------------+--------+-------+-------+
102-
| | Footer || | |
103-
+ +-----------------------+--------+-------+-------+
104-
| | Footnote || | |
105-
+ +-----------------------+--------+-------+-------+
106-
| | Endnote || | |
107-
+-------------------------+-----------------------+--------+-------+-------+
108-
| **Graphs** | 2D basic graphs | | | |
109-
+ +-----------------------+--------+-------+-------+
110-
| | 2D advanced graphs | | | |
111-
+ +-----------------------+--------+-------+-------+
112-
| | 3D graphs | | | |
113-
+-------------------------+-----------------------+--------+-------+-------+
114-
| **Math** | OMML support | | | |
115-
+ +-----------------------+--------+-------+-------+
116-
| | MathML support | | | |
117-
+-------------------------+-----------------------+--------+-------+-------+
118-
| **Bonus** | Encryption | | | |
119-
+ +-----------------------+--------+-------+-------+
120-
| | Protection | | | |
121-
+-------------------------+-----------------------+--------+-------+-------+
65+
+-------------------------------------------------+--------+-------+-------+-------+-------+
66+
| Features | DOCX | ODT | RTF | HTML | PDF |
67+
+=========================+=======================+========+=======+=======+=======+=======+
68+
| **Document Properties** | Standard | | | | | |
69+
+ +-----------------------+--------+-------+-------+-------+-------+
70+
| | Extended | | | | | |
71+
+ +-----------------------+--------+-------+-------+-------+-------+
72+
| | UserDefined | | | | | |
73+
+-------------------------+-----------------------+--------+-------+-------+-------+-------+
74+
| **Element Type** | Text ||||||
75+
+ +-----------------------+--------+-------+-------+-------+-------+
76+
| | Text Run ||||||
77+
+ +-----------------------+--------+-------+-------+-------+-------+
78+
| | Title || | |||
79+
+ +-----------------------+--------+-------+-------+-------+-------+
80+
| | Link || | |||
81+
+ +-----------------------+--------+-------+-------+-------+-------+
82+
| | Preserve Text || | | | |
83+
+ +-----------------------+--------+-------+-------+-------+-------+
84+
| | Text Break ||||||
85+
+ +-----------------------+--------+-------+-------+-------+-------+
86+
| | Page Break || | | | |
87+
+ +-----------------------+--------+-------+-------+-------+-------+
88+
| | List || | | | |
89+
+ +-----------------------+--------+-------+-------+-------+-------+
90+
| | Table || | || |
91+
+ +-----------------------+--------+-------+-------+-------+-------+
92+
| | Image || | || |
93+
+ +-----------------------+--------+-------+-------+-------+-------+
94+
| | Object || | | | |
95+
+ +-----------------------+--------+-------+-------+-------+-------+
96+
| | Watermark || | | | |
97+
+ +-----------------------+--------+-------+-------+-------+-------+
98+
| | Table of Contents || | | | |
99+
+ +-----------------------+--------+-------+-------+-------+-------+
100+
| | Header || | | | |
101+
+ +-----------------------+--------+-------+-------+-------+-------+
102+
| | Footer || | | | |
103+
+ +-----------------------+--------+-------+-------+-------+-------+
104+
| | Footnote || | || |
105+
+ +-----------------------+--------+-------+-------+-------+-------+
106+
| | Endnote || | || |
107+
+-------------------------+-----------------------+--------+-------+-------+-------+-------+
108+
| **Graphs** | 2D basic graphs | | | | | |
109+
+ +-----------------------+--------+-------+-------+-------+-------+
110+
| | 2D advanced graphs | | | | | |
111+
+ +-----------------------+--------+-------+-------+-------+-------+
112+
| | 3D graphs | | | | | |
113+
+-------------------------+-----------------------+--------+-------+-------+-------+-------+
114+
| **Math** | OMML support | | | | | |
115+
+ +-----------------------+--------+-------+-------+-------+-------+
116+
| | MathML support | | | | | |
117+
+-------------------------+-----------------------+--------+-------+-------+-------+-------+
118+
| **Bonus** | Encryption | | | | | |
119+
+ +-----------------------+--------+-------+-------+-------+-------+
120+
| | Protection | | | | | |
121+
+-------------------------+-----------------------+--------+-------+-------+-------+-------+
122122

123123

124124
Readers

samples/Sample_07_TemplateCloneRow.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,8 @@
6060
$document->saveAs($name);
6161
rename($name, "results/{$name}");
6262

63-
include_once 'Sample_Footer.php';
63+
$writers = array('Word2007' => 'docx');
64+
echo getEndingNotes($writers);
65+
if (!CLI) {
66+
include_once 'Sample_Footer.php';
67+
}

samples/Sample_23_TemplateBlock.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,8 @@
1818
$document->saveAs($name);
1919
rename($name, "results/{$name}");
2020

21-
include_once 'Sample_Footer.php';
21+
$writers = array('Word2007' => 'docx');
22+
echo getEndingNotes($writers);
23+
if (!CLI) {
24+
include_once 'Sample_Footer.php';
25+
}

samples/Sample_Header.php

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,17 @@
4646
}
4747

4848
/**
49-
* Get results
49+
* Write documents
5050
*
5151
* @param \PhpOffice\PhpWord\PhpWord $phpWord
5252
* @param string $filename
5353
* @param array $writers
54-
* @return string
5554
*/
5655
function write($phpWord, $filename, $writers)
5756
{
5857
$result = '';
5958

60-
// Write
59+
// Write documents
6160
foreach ($writers as $writer => $extension) {
6261
$result .= date('H:i:s') . " Write to {$writer} format";
6362
if (!is_null($extension)) {
@@ -70,6 +69,20 @@ function write($phpWord, $filename, $writers)
7069
$result .= EOL;
7170
}
7271

72+
$result .= getEndingNotes($writers);
73+
74+
return $result;
75+
}
76+
77+
/**
78+
* Get ending notes
79+
*
80+
* @param array $writers
81+
*/
82+
function getEndingNotes($writers)
83+
{
84+
$result = '';
85+
7386
// Do not show execution time for index
7487
if (!IS_INDEX) {
7588
$result .= date('H:i:s') . " Done writing file(s)" . EOL;
@@ -85,9 +98,11 @@ function write($phpWord, $filename, $writers)
8598
$result .= '<p>&nbsp;</p>';
8699
$result .= '<p>Results: ';
87100
foreach ($types as $type) {
88-
$resultFile = 'results/' . SCRIPT_FILENAME . '.' . $type;
89-
if (file_exists($resultFile)) {
90-
$result .= "<a href='{$resultFile}' class='btn btn-primary'>{$type}</a> ";
101+
if (!is_null($type)) {
102+
$resultFile = 'results/' . SCRIPT_FILENAME . '.' . $type;
103+
if (file_exists($resultFile)) {
104+
$result .= "<a href='{$resultFile}' class='btn btn-primary'>{$type}</a> ";
105+
}
91106
}
92107
}
93108
$result .= '</p>';

0 commit comments

Comments
 (0)