[TikiWiki-commits] [Git][tikiwiki/tiki][27.x] [ENH] pdf print ajax service

"Victor Emanouilov \(@kroky\) via TikiWiki-cvs" <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <6914472af261c_2cc72d4c32586@gitlab-sidekiq-low-urgency-cpu-bound-v2-7898cb4754-frn8t.mail>

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


Commits:
9739ad41 by Victor Emanouilov at 2025-11-12T10:36:47+02:00
[ENH] pdf print ajax service
---
* [FIX] pipeline

* [ENH] pdf print ajax service

See merge request tikiwiki/tiki!9010

- - - - -


2 changed files:

- doc/devtools/codesniffer/standards/TikiIgnore/ignore_list.json
- lib/core/Services/PDF/Controller.php


Changes:

=====================================
doc/devtools/codesniffer/standards/TikiIgnore/ignore_list.json
=====================================
@@ -8816,6 +8816,7 @@
             "XMPPLib::get_groups": true
         },
         "lib\/core\/Services\/PDF\/Controller.php": {
+            "Services_PDF_Controller::action_get_pdf": true,
             "Services_PDF_Controller::action_storeTable": true,
             "Services_PDF_Controller::action_checkPDFFile": true
         },


=====================================
lib/core/Services/PDF/Controller.php
=====================================
@@ -11,6 +11,35 @@ class Services_PDF_Controller
         Services_Exception_Disabled::check('feature_wiki_print');
     }
 
+    public function action_get_pdf($input)
+    {
+        // edit permission is needed to convert arbitrary text to PDF
+        if (! Perms::get()->edit) {
+            throw new Services_Exception_Denied();
+        }
+
+        $contents = $input->contents->html();
+        $filename = $input->filename->text();
+
+        if (empty($filename)) {
+            $filename = 'contents.pdf';
+        }
+
+        require_once 'lib/pdflib.php';
+        $generator = new PdfGenerator();
+        if (! empty($generator->error)) {
+            Feedback::error($generator->error);
+            return "";
+        } else {
+            $pdf = $generator->getPdf('tiki-print.php', [], $contents);
+            header('Content-Type: application/pdf');
+            header('Content-Disposition: attachment; filename="' . $filename . '"');
+            header('Content-Length: ' . strlen($pdf));
+            echo $pdf;
+            exit;
+        }
+    }
+
     //function added to hold current state of fancy table / sorted table for pdf and print version. So when user generates pdf he gets his sorted data not default data in table.
     public function action_storeTable($input)
     {



View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/9739ad4176b39feb784c75cb9bec23c6e7f71d02

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