[TikiWiki-commits] [Git][tikiwiki/tiki][29.x] [BP][FIX] slide show printing: failed to print large table and missing themes style.

"Boss Ibrahim Mussa Gregoire \(@bim-g\) via TikiWiki-cvs" <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <69525aa046440_2a17fd684533@gitlab-sidekiq-low-urgency-cpu-bound-v2-5bd8dbbcb-q27cs.mail>

Boss Ibrahim Mussa Gregoire pushed to branch 29.x at Tiki Wiki CMS Groupware / Tiki


Commits:
e6387cfe by Boss Ibrahim Mussa Gregoire at 2025-12-29T11:32:56+01:00
[BP][FIX] slide show printing: failed to print large table and missing themes style.
---
* [FIX] slide show printing: failed to print large table and missing themes style.

See merge request tikiwiki/tiki!9284

- - - - -


5 changed files:

- lib/pdflib.php
- lib/wiki-plugins/wikiplugin_slideshow.php
- lib/wiki-plugins/wikiplugin_slideshowslide.php
- templates/tiki_full.tpl
- tiki-slideshow.php


Changes:

=====================================
lib/pdflib.php
=====================================
@@ -324,6 +324,9 @@ class PdfGenerator
         $mpdf = new \Mpdf\Mpdf($mpdfConfig);
         $mpdf->curlAllowUnsafeSslRequests = ($prefs['print_pdf_mpdf_allow_unsafe_ssl_requests'] ?? 'y') === 'y';
 
+        $basePath = $params['base_path'] ?? TIKI_PATH ;
+        $mpdf->SetBasePath($basePath);
+
         //custom fonts add, currently fontawesome support is added, more fonts can be added in future
         $custom_fontdata = [
          'fontawesome' => [
@@ -364,7 +367,6 @@ class PdfGenerator
         } else {
             $extcss = '';
         }
-
         // checking if print friendly preference is enabled if so then attach print css
         // otherwise theme styles will be retained by theme css
         $themecss = '';


=====================================
lib/wiki-plugins/wikiplugin_slideshow.php
=====================================
@@ -49,6 +49,7 @@ function wikiplugin_slideshow_info()
                 'accepted' => tra('Valid URL'),
                 'default' => '',
                 'since' => '19.0',
+                'default' => '',
             ],
             'parallaxBackgroundSize' => [
                 'required' => false,
@@ -293,7 +294,7 @@ function wikiplugin_slideshow($data, $params)
 
     $headerlib = TikiLib::lib('header');
     if (! isset($_REQUEST['theme'])) {
-        $headerlib->add_cssfile(REVEALJS_DIST_PATH . "./theme/" . $params['theme'] . '.css', 1);
+        $headerlib->add_cssfile(REVEALJS_DIST_PATH . "/theme/" . $params['theme'] . '.css', 1);
         $headerlib->add_js(
             '$( "#showtheme" ).val( "' . $params['theme'] . '" );'
         );


=====================================
lib/wiki-plugins/wikiplugin_slideshowslide.php
=====================================
@@ -103,6 +103,7 @@ function wikiplugin_slideshowslide_info()
                 'filter' => 'word',
                 'default' => '',
                 'since' => '19.0',
+                'default' => 'none',
                 'options' => [
                     ['text' => 'None', 'value' => 'none'],
                     ['text' => 'Fade', 'value' => 'fade'],
@@ -119,6 +120,7 @@ function wikiplugin_slideshowslide_info()
                 'filter' => 'word',
                 'default' => '',
                 'since' => '19.0',
+                'default' => 'none',
                 'options' => [
                     ['text' => 'None', 'value' => 'none'],
                     ['text' => 'Fade', 'value' => 'fade'],


=====================================
templates/tiki_full.tpl
=====================================
@@ -3,7 +3,7 @@
 <head>
     {include file='header.tpl'}
 </head>
-<body{html_body_attributes}>
+<body{if $printpdf ne 'y'}{$html_body_attributes}{/if}>
 
 {* Index we display a wiki page here *}
 {if Language::isRTL()}
@@ -15,16 +15,11 @@
 {if $is_slideshow eq 'y'}
     <div class="reveal">
         <div class="slides">
-{else}
-    <div id="main">
-        <div id="tiki-center">
-            <div id="role_main">
-{/if}
-
-{$mid_data}
-{if $is_slideshow eq 'y'}
+            {$mid_data}
+        </div>
     </div>
-        <div id="ss-settings-holder" title="Click for slideshow operations"><span class="fas fa-cogs" style="font-size:1rem;color:#666" id="ss-settings"></span></div>
+    {if $printpdf ne 'y'}
+        <div id="ss-settings-holder" title="{tr}Click for slideshow operations{/tr}"><span class="fas fa-cogs" style="font-size:1rem;color:#666" id="ss-settings"></span></div>
         <div id="ss-options" class="d-flex flex-row justify-content-around align-content-end flex-wrap">
             <div class="p-2">
                 <select id="showtheme" class="form-control">
@@ -43,17 +38,22 @@
                     <option value="">{tr}Off{/tr}</option>
                 </select>
             </div>
-            <div class="p-2" id="reveal-controls"><span class="fas fa-fast-backward me-1"  id="firstSlide" title="Go to First Slide"></span><span class="fas fa-step-backward me-1" id="prevSlide" title="Go to Previous Slide"></span><span class="fas fa-play-circle me-1" id="play"></span><span class="fas fa-undo me-1 icon-inactive" id="loop" title="Auto-play in loop"></span><span class="fas fa-step-forward me-1"  id="nextSlide" title="Go to Next Slide"></span><span class="fas fa-fast-forward"  id="lastSlide" title="Go to Last Slide"></span></div>
-            <div class="p-2" id="listSlides"><span class="fas fa-list me-1"   title="List Slides"></span> List Slides</div>
+            <div class="p-2" id="reveal-controls"><span class="fas fa-fast-backward me-1"  id="firstSlide" title="{tr}Go to First Slide{/tr}"></span><span class="fas fa-step-backward me-1" id="prevSlide" title="{tr}Go to Previous Slide{/tr}"></span><span class="fas fa-play-circle me-1" id="play"></span><span class="fas fa-undo me-1 icon-inactive" id="loop" title="{tr}Auto-play in loop{/tr}"></span><span class="fas fa-step-forward me-1"  id="nextSlide" title="{tr}Go to Next Slide{/tr}"></span><span class="fas fa-fast-forward"  id="lastSlide" title="{tr}Go to Last Slide{/tr}"></span></div>
+            <div class="p-2" id="listSlides"><span class="fas fa-list me-1"   title="{tr}List Slides{/tr}"></span>{tr}List Slides{/tr}</div>
 
             {if $prefs.feature_slideshow_pdfexport eq 'y'}
-                <div class="p-2"><a href="tiki-slideshow.php?page={$page}&pdf=1&landscape=1" target="_blank" id="exportPDF"><span class="far fa-file-pdf"></span> {tr}Export PDF{/tr}</a></div>
-                <div class="p-2"><a href="tiki-slideshow.php?page={$page}&pdf=1&printslides=1" target="_blank"><span class="fas fa-print"></span> {tr} Handouts{/tr}</a></div>
+                <div class="p-2"><a href="tiki-slideshow.php?page={$page}&print-pdf=1" target="_blank" id="exportPDF"><span class="far fa-file-pdf"></span>{tr}Export PDF{/tr}</a></div>
+                <div class="p-2"><a href="tiki-slideshow.php?page={$page}&pdf=1&landscape=1" target="_blank"><span class="fas fa-print"></span>{tr}Handouts{/tr}</a></div>
             {/if}
 
-            <div class="p-2"><a href="tiki-index.php?page={$page}"><span class="fas fa-sign-out-alt"></span> {tr}Exit Slideshow{/tr}</a></div>
+            <div class="p-2"><a href="tiki-index.php?page={$page}"><span class="fas fa-sign-out-alt"></span>{tr}Exit Slideshow{/tr}</a></div>
         </div>
+    {/if}
 {else}
+    <div id="main">
+        <div id="tiki-center">
+            <div id="role_main">
+                {$mid_data}
             </div>
         </div>
     </div>


=====================================
tiki-slideshow.php
=====================================
@@ -133,6 +133,13 @@ if (! empty($slidePluginData)) {
 }
 
 $pdata = formatContent($pdata, $tagsArr, $slidePluginHeadingLevelSlideSeparator);
+$pdata = formatContent($pdata, $tagsArr, $slidePluginHeadingLevelSlideSeparator);
+
+$revealJsThemesPath = REVEALJS_DIST_PATH . '/theme/';
+$revealJsCssFile = REVEALJS_DIST_PATH . '/reveal.css';
+$revealJsJsFile = REVEALJS_DIST_PATH . '/reveal.js';
+$revealThemeFile = $revealJsThemesPath . $theme . '.css';
+$params['base_path'] = REVEALJS_DIST_PATH;
 
 if (isset($_REQUEST['pdf'])) {
     $access->check_feature("feature_slideshow_pdfexport");
@@ -176,61 +183,51 @@ if (isset($_REQUEST['pdf'])) {
         // initialize background image
         $imgBackgroundCSS = '';
 
-        //checking if to export slideshow
-        if (isset($_REQUEST['printslides'])) {
-            $customCSS
-                = "<style type='text/css'>img{max-height:300px;width:auto;} body{font-size:1em} h1{font-size:1.5em;text-transform:none !important;}  section{height:300px;border:1px solid #000;margin-bottom:1%;padding:1%;}</style> ";
-            $pdata = $customCSS . '<pdfsettings printFriendly="y" header="off" footer="off"></pdfsettings>' . $pdata;
-        } else {
-            $doc = new DOMDocument();
-            libxml_use_internal_errors(true);
-            $doc->loadHTML('<html lang="en"><head><meta charset="UTF-8"></head><body>' . $pdata . '</body></html>', LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
-            libxml_clear_errors();
-
-            $sections = $doc->getElementsByTagName('section');
-
-            foreach ($sections as $key => $section) {
-                // Remove saveHTML call
-                $color = $section->getAttribute('data-background-color');
-                $imgBackground = $section->getAttribute('data-background-image');
-
-                if (! empty($imgBackground)) {
-                    $class = $section->getAttribute('class');
-                    $section->setAttribute("class", 'section_bg_image_' . $key . ' ' . $class);
-
-                    $imgBackgroundCSS .= ' .section_bg_image_' . $key . '{
-                        background-image: url("' . $imgBackground . '");
-                        background-position: top left;
-                        background-repeat: no-repeat;
-                        background-image-resize: 4;
-                        background-image-resolution: from-image;
-                    }';
-                }
+        $doc = new DOMDocument();
+        libxml_use_internal_errors(true);
+        $doc->loadHTML('<html lang="en"><head><meta charset="UTF-8"></head><body>' . $pdata . '</body></html>', LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
+        libxml_clear_errors();
+
+        $sections = $doc->getElementsByTagName('section');
+
+        foreach ($sections as $key => $section) {
+            // Remove saveHTML call
+            $color = $section->getAttribute('data-background-color');
+            $imgBackground = $section->getAttribute('data-background-image');
+
+            if (! empty($imgBackground)) {
+                $class = $section->getAttribute('class');
+                $section->setAttribute("class", 'section_bg_image_' . $key . ' ' . $class);
+
+                $imgBackgroundCSS .= ' .section_bg_image_' . $key . '{
+                    background-image: url("' . $imgBackground . '");
+                    background-position: top left;
+                    background-repeat: no-repeat;
+                    background-image-resize: 4;
+                    background-image-resolution: from-image;
+                }';
+            }
 
-                if (! empty($color)) {
-                    $style = $section->getAttribute('style');
-                    $section->setAttribute("style", "background-color:" . $color . ";" . $style);
-                }
+            if (! empty($color)) {
+                $style = $section->getAttribute('style');
+                $section->setAttribute("style", "background-color:" . $color . ";" . $style);
             }
+        }
 
-            $pdata = $doc->saveHTML();
+        $pdata = $doc->saveHTML();
 
-            //getting css
-            $customCSS = file_get_contents(
-                REVEALJS_DIST_PATH . '/reveal.css'
-            );
-            $customCSS .= file_get_contents(
-                REVEALJS_DIST_PATH . '/' . 'theme/' . $theme . '.css'
-            );
+        //getting css
+        $customCSS = file_get_contents($revealJsCssFile);
+        $customCSS .= file_get_contents($revealThemeFile);
+
+        $customCSS .= '.reveal section{width:100%; height:100%;text-align:center;margin:auto;} section{text-align:center;margin: auto;width:100%;} .ss-heading{line-height:2.5em,padding-bottom:20px;} ' . $imgBackgroundCSS;
+        $pdata = '<pdfsettings header="off" footer="off" margin_top="0" margin_bottom="0" margin_left="0" margin_right="0" printfriendly="n"></pdfsettings><div class="reveal">' . $pdata . '</div>';
+        $pdata = str_replace(
+            "</section><section",
+            "</section><pagebreak /><section",
+            $pdata . '<style>' . str_replace([".reveal {","vertical-align: baseline;"], [".reveal,.reveal table{ ","vertical-align:top;"], $customCSS) . ' div.reveal, .reveal li{font-size:1.3em;font-weight:normal;line-height:1.5;height:auto !important; } img{max-height:400px;}  .reveal h1 {font-size: 2.8em; text-transform:none !important;} .reveal li ul li {font-size: 0.95em !important;margin: 0em !important;}</style>'
+        ) . $pdfStyles;
 
-            $customCSS .= '.reveal section{width:100%; height:100%;text-align:center;margin:auto;} section{text-align:center;margin: auto;width:100%;} .ss-heading{line-height:2.5em,padding-bottom:20px;} ' . $imgBackgroundCSS;
-            $pdata = '<pdfsettings header="off" footer="off" margin_top="0" margin_bottom="0" margin_left="0" margin_right="0" printfriendly="n"></pdfsettings><div class="reveal">' . $pdata . '</div>';
-            $pdata = str_replace(
-                "</section><section",
-                "</section><pagebreak /><section",
-                $pdata . '<style>' . str_replace([".reveal {","vertical-align: baseline;"], [".reveal,.reveal table{ ","vertical-align:top;"], $customCSS) . ' div.reveal, .reveal li{font-size:1.3em;font-weight:normal;line-height:1.5;height:auto !important; } img{max-height:400px;}  .reveal h1 {font-size: 2.8em; text-transform:none !important;} .reveal li ul li {font-size: 0.95em !important;margin: 0em !important;}</style>'
-            ) . $pdfStyles;
-        }
 
         $pdf = $generator->getPdf(
             $filename,
@@ -262,17 +259,9 @@ $smarty->assign_by_ref('lastUser', $info["user"]);
 
 include_once('tiki-section_options.php');
 
-
-$headerlib->add_jsfile(
-    REVEALJS_DIST_PATH . '/reveal.js'
-);
-$headerlib->add_cssfile(
-    REVEALJS_DIST_PATH . '/reveal.css'
-);
-$headerlib->add_cssfile(
-    REVEALJS_DIST_PATH . '/' . 'theme/' . $theme
-                . '.css'
-);
+$headerlib->add_jsfile($revealJsJsFile);
+$headerlib->add_cssfile($revealJsCssFile);
+$headerlib->add_cssfile($revealThemeFile);
 
 $headerlib->add_css(<<<CSS
     .reveal span {
@@ -451,7 +440,32 @@ $headerlib->add_jq_onready(<<<JS
             }
         </style>
     `);
-
+JS);
+
+if (isset($_REQUEST['print-pdf']) && $_REQUEST['print-pdf'] == 1) {
+    $smarty->assign('printpdf', 'y');
+    $headerlib->add_jq_onready(<<<JS
+    Reveal.initialize({ 
+        width: 960,
+        height: 700,
+        slideNumber: false,
+        controls: false,
+        progress: false,
+        center: true,
+        embedded: true,
+        pdfSeparateFragments: false,
+        // disableLayout: true,
+        showNotes: "separate-page", 
+    });
+    Reveal.addEventListener('ready', () => {
+        setTimeout(() => {
+          window.print();
+        }, 1000); // longer delay for heavy assets
+    });
+JS);
+} else {
+    $headerlib->add_jq_onready(
+        <<<JS
     var extraElements=["#page-bar",".icon_edit_section",".icon-link-external",".editplugin","#show-errors-button",".wikitext",".icon_edit_section","#toc","footer",".heading-link"];
 
     jQuery.each( extraElements, function( i, val ) {
@@ -531,7 +545,7 @@ $headerlib->add_jq_onready(<<<JS
 
         $( "#showtheme" ).on("change", function() {
             var selectedCSS=$("#showtheme" ).val();
-            $("#themeCSS").attr("href","' . REVEALJS_DIST_PATH . '/theme/"+selectedCSS+".css");
+            $("#themeCSS").attr("href","$revealJsThemesPath"+selectedCSS+".css");
         });
         $( "#showtransition" ).on("change", function() {
             var selectedTransition=$("#showtransition" ).val();
@@ -581,8 +595,8 @@ $headerlib->add_jq_onready(<<<JS
              }
         });
 JS
-);
-
+    );
+}
 $params = [];
 
 foreach ($_GET as $key => $value) {



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

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