[TikiWiki-commits] [Git][tikiwiki/tiki][26.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 <692d72f43a0ca_2a1388a64828f@gitlab-sidekiq-low-urgency-cpu-bound-v2-7879b95b78-w659x.mail>

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


Commits:
7d4647c5 by Victor Emanouilov at 2025-12-01T12:50:21+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/7d4647c57a5eb749f319aebfb3658c44df26fa13

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