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

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

Victor Emanouilov pushed to branch 29.x at Tiki Wiki CMS Groupware / Tiki


Commits:
435172a0 by Victor Emanouilov at 2025-12-01T12:49:48+02: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/435172a061b5481203733c9e76d0cad830616fe9

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/435172a061b5481203733c9e76d0cad830616fe9
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.