-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from b13/release
Release
- Loading branch information
Showing
8 changed files
with
153 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,45 @@ | ||
plugin.tx_format { | ||
settings { | ||
typeNum = 1386239798 | ||
pdf { | ||
// Path to the wkhtmltopdf binary | ||
binaryFilePath = /usr/local/bin/wkhtmltopdf | ||
// Path were the PDFs are stored | ||
tempDirectoryPath = /tmp/ | ||
// Default file name of the generated PDF | ||
tempFileName = | ||
cacheSeconds = 3600 | ||
// If set the fileName will be appended with X characters of the md5 hash of the content | ||
md5Length = 0 | ||
// Use print media-type instead of screen | ||
printMediaTypeAttribute = 1 | ||
// Generates lower quality pdf/ps. Useful to shrink the result document space | ||
lowQualityAttribute = 0 | ||
// Adds a html footer | ||
footerHtmlAttribute = | ||
// URL to render (instead of content) | ||
url = | ||
// Minimum font size | ||
minimumFontSize = 15 | ||
// Set the page left margin (default 10mm) | ||
marginLeft = 10 | ||
// Set the page right margin (default 10mm) | ||
marginRight = 10 | ||
// Set the page top margin | ||
marginTop = 10 | ||
// Set the page bottom margin | ||
marginBottom = 10 | ||
// The default page size of the rendered document is A4, but using this | ||
// --page-size optionthis can be changed to almost anything else, such as: A3, | ||
// Letter and Legal. For a full list of supported pages sizes please see | ||
// <http://qt-project.org/doc/qt-4.8/qprinter.html#PaperSize-enum>. | ||
pageSize = | ||
// 200 is default for wkhtmltopdf | ||
// Wait some milliseconds for javascript finish (default 200) | ||
javaScriptDelay = 200 | ||
// Set orientation to Landscape or Portrait (default Portrait) | ||
orientation = Portrait | ||
// Whether a generated PDF should be kept at the end of the process. By default it is deleted | ||
// Whether a generated PDF should be kept at the end of the process. By default it is deleted. | ||
persistPDF = 0 | ||
// For all supported attributes refer to https://wkhtmltopdf.org/usage/wkhtmltopdf.txt | ||
additionalAttributes = | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,100 @@ | ||
t3ext-format | ||
============ | ||
#TYPO3 Extension format | ||
|
||
Helper extension to allow easy use of putting data in different formats (CSV, Excel, PDF etc) | ||
Utility Extension for putting data in different formats like | ||
|
||
* CSV | ||
* Excel | ||
|
||
## Installation | ||
|
||
Simply install the extension with Composer or the Extension Manager. Include the TypoScript if you want to use the PDF generation. | ||
|
||
## Usage | ||
|
||
### CSV | ||
|
||
Use the public API of the `CsvService` to generate a CSV file or output the CSV string directly. | ||
|
||
### Excel | ||
|
||
There is no wrapper functionality to help with the creation of excel files. However the library | ||
`phpoffice/phpspreadsheet` is required as a composer dependency and can therefore be used out of | ||
the box in composer based installations. | ||
|
||
|
||
The PDF functionality relies on wkhtmltopdf which must be available on the server. | ||
There are several ways to provide the binary. Please refer to the wkhtmltopdf documentation. | ||
|
||
The extension provides a PdfService. here is an example usage: | ||
|
||
``` | ||
$pdfService = GeneralUtility::makeInstance(PdfService::class); | ||
$pdfService->setContent($myHtml); | ||
$absolutepathToFile = $pdfService->saveToFile('myPdf.pdf'); | ||
``` | ||
|
||
This will create a file `myPdf.pdf` with the contents of `$myHtml` in a directory that can be configured in TypoScript. | ||
The whole TypoScript configuration (`constants.typoscript`): | ||
|
||
``` | ||
plugin.tx_format { | ||
settings { | ||
pdf { | ||
// Path to the wkhtmltopdf binary | ||
binaryFilePath = /usr/local/bin/wkhtmltopdf | ||
// Path were the PDFs are stored | ||
tempDirectoryPath = /tmp/ | ||
// Default file name of the generated PDF | ||
tempFileName = | ||
// If set the fileName will be appended with X characters of the md5 hash of the content | ||
md5Length = 0 | ||
// Use print media-type instead of screen | ||
printMediaTypeAttribute = 1 | ||
// Generates lower quality pdf/ps. Useful to shrink the result document space | ||
lowQualityAttribute = 0 | ||
// Adds a html footer | ||
footerHtmlAttribute = | ||
// URL to render (instead of content) | ||
url = | ||
// Minimum font size | ||
minimumFontSize = 15 | ||
// Set the page left margin (default 10mm) | ||
marginLeft = 10 | ||
// Set the page right margin (default 10mm) | ||
marginRight = 10 | ||
// Set the page top margin | ||
marginTop = 10 | ||
// Set the page bottom margin | ||
marginBottom = 10 | ||
// The default page size of the rendered document is A4, but using this | ||
// --page-size optionthis can be changed to almost anything else, such as: A3, | ||
// Letter and Legal. For a full list of supported pages sizes please see | ||
// <http://qt-project.org/doc/qt-4.8/qprinter.html#PaperSize-enum>. | ||
pageSize = | ||
// Wait some milliseconds for javascript finish (default 200) | ||
javaScriptDelay = 200 | ||
// Set orientation to Landscape or Portrait (default Portrait) | ||
orientation = Portrait | ||
// Whether a generated PDF should be kept at the end of the process. By default it is deleted. | ||
persistPDF = 0 | ||
// For all supported attributes refer to https://wkhtmltopdf.org/usage/wkhtmltopdf.txt | ||
additionalAttributes = | ||
} | ||
} | ||
} | ||
``` | ||
|
||
Every setting can be overwritten during runtime: | ||
|
||
``` | ||
$pdfService = GeneralUtility::makeInstance(PdfService::class); | ||
$pdfService->setSettings( | ||
[ | ||
'orientation' => 'Landscape, | ||
'marginLeft' => 25, | ||
'tempDirectoryPath' => PATH_site . 'something/public/' | ||
] | ||
); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters