[TikiWiki-commits] [Git][tikiwiki/tiki][master] [FIX] add printable pdf settings to ajax service

"Victor Emanouilov \(@kroky\) via TikiWiki-cvs" <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <692d706d5b692_2aff50b4170c8@gitlab-sidekiq-low-urgency-cpu-bound-v2-7879b95b78-2d96k.mail>

Victor Emanouilov pushed to branch master at Tiki Wiki CMS Groupware / Tiki


Commits:
72a0da8c by Victor Emanouilov at 2025-12-01T10:31:39+00:00
[FIX] add printable pdf settings to ajax service
---
* [FIX] pipeline

* [FIX] add printable pdf settings to ajax service

See merge request tikiwiki/tiki!9158

- - - - -


1 changed file:

- lib/core/Services/PDF/Controller.php


Changes:

=====================================
lib/core/Services/PDF/Controller.php
=====================================
@@ -13,6 +13,8 @@ class Services_PDF_Controller
 
     public function action_get_pdf($input)
     {
+        global $prefs;
+
         // edit permission is needed to convert arbitrary text to PDF
         if (! Perms::get()->edit) {
             throw new Services_Exception_Denied();
@@ -21,6 +23,23 @@ class Services_PDF_Controller
         $contents = $input->contents->html();
         $filename = $input->filename->text();
 
+        $pdfsettings = $input->pdfsettings->json();
+        if ($pdfsettings) {
+            $pdfsettings = json_decode($pdfsettings, true);
+        }
+        if ($pdfsettings) {
+            $allowed_keys = [];
+            foreach ($prefs as $key => $_) {
+                if (str_starts_with($key, 'print_pdf_mpdf_')) {
+                    $allowed_keys[] = str_replace('print_pdf_mpdf_', '', $key);
+                }
+            }
+            $pdfsettings = array_intersect_key($pdfsettings, array_flip($allowed_keys));
+            $contents = "<pdfsettings " . implode('', array_map(function ($key) use ($pdfsettings) {
+                return $key . '="' . htmlspecialchars($pdfsettings[$key]) . '" ';
+            }, array_keys($pdfsettings))) . "></pdfsettings>" . $contents;
+        }
+
         if (empty($filename)) {
             $filename = 'contents.pdf';
         }



View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/72a0da8c182d88d21029699cc456c17597b3166f

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/72a0da8c182d88d21029699cc456c17597b3166f
You're receiving this email because of your account on gitlab.com.

_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.