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

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

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


Commits:
251f12bc by Victor Emanouilov at 2025-11-12T10:34:06+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
=====================================
@@ -7146,6 +7146,7 @@
             "Services_OAuthServer_Controller::action_public_key": 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/251f12bc8ae0cc90f231c8bfa2d0f1878764b4fc

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