# Maximum file size, in megabytes, that can be uploaded to the system.
FILE_UPLOAD_SIZE_LIMIT=50
+# Export Page Size
+# Primarily used to determine page size of PDF exports.
+# Can be 'a4' or 'letter'.
+EXPORT_PAGE_SIZE=a4
+
# Allow <script> tags in page content
# Note, if set to 'true' the page editor may still escape scripts.
ALLOW_CONTENT_SCRIPTS=false
* Do not edit this file unless you're happy to maintain any changes yourself.
*/
+$dompdfPaperSizeMap = [
+ 'a4' => 'a4',
+ 'letter' => 'letter',
+];
+
return [
'show_warnings' => false, // Throw an Exception on warnings from dompdf
*
* @see CPDF_Adapter::PAPER_SIZES for valid sizes ('letter', 'legal', 'A4', etc.)
*/
- 'default_paper_size' => 'a4',
+ 'default_paper_size' => $dompdfPaperSizeMap[env('EXPORT_PAGE_SIZE', 'a4')] ?? 'a4',
/**
* The default font family.
* Do not edit this file unless you're happy to maintain any changes yourself.
*/
+$snappyPaperSizeMap = [
+ 'a4' => 'A4',
+ 'letter' => 'Letter',
+];
+
return [
'pdf' => [
'enabled' => true,
'timeout' => false,
'options' => [
'outline' => true,
+ 'page-size' => $snappyPaperSizeMap[env('EXPORT_PAGE_SIZE', 'a4')] ?? 'A4',
],
'env' => [],
],
$this->checkEnvConfigResult('ALLOW_UNTRUSTED_SERVER_FETCHING', 'true', 'dompdf.defines.enable_remote', true);
}
+ public function test_dompdf_paper_size_options_are_limited()
+ {
+ $this->checkEnvConfigResult('EXPORT_PAGE_SIZE', 'cat', 'dompdf.defines.default_paper_size', 'a4');
+ $this->checkEnvConfigResult('EXPORT_PAGE_SIZE', 'letter', 'dompdf.defines.default_paper_size', 'letter');
+ $this->checkEnvConfigResult('EXPORT_PAGE_SIZE', 'a4', 'dompdf.defines.default_paper_size', 'a4');
+ }
+
+ public function test_snappy_paper_size_options_are_limited()
+ {
+ $this->checkEnvConfigResult('EXPORT_PAGE_SIZE', 'cat', 'snappy.pdf.options.page-size', 'A4');
+ $this->checkEnvConfigResult('EXPORT_PAGE_SIZE', 'letter', 'snappy.pdf.options.page-size', 'Letter');
+ $this->checkEnvConfigResult('EXPORT_PAGE_SIZE', 'a4', 'snappy.pdf.options.page-size', 'A4');
+ }
+
/**
* Set an environment variable of the given name and value
* then check the given config key to see if it matches the given result.