Search code examples
phppdf-generationcontent-management-systemwkhtmltopdftiki-wiki

CMS and store hi-resolution images in generated pdf


I'm looking for good CMS for publishing software manuals.

Requirements:

  • publish manual pages as web pages with thumbnails and shows full resolution after click on image,
  • exporting manual pages to a pdf file with full resolution images instead to thumbnails.

I found IMHO best wiki system named Tiki Wiki (https://info.tiki.org/) but when I export to pdf then I gets low resolution thumbnail.


Solution

  • I solve this problem by very simple Tiki Wiki code modification:

    Modify lib/wiki-plugins/wikiplugin_img.php to force using full image resolution instead to thumbnail in print page mode (inserted code 1) and rescale images in generated HTML by 0.5 factor (inserted code 2):

    [...]
    
    function wikiplugin_img( $data, $params )
    {
        [...]
    
        $imgdata = array_merge($imgdata, $params);
    
        // inserted code 1 (~410 line)
        if ($GLOBALS['section_class']=="tiki_wiki_page print"){
            $imgdata['thumb'] = '';
        }
        // end of inserted code 1
    
        //function calls
        if ( !empty($imgdata['default']) || !empty($imgdata['mandatory'])) {
    
        [...]
    
        $fwidth = '';
        $fheight = '';
        if (isset(TikiLib::lib('parser')->option['indexing']) && TikiLib::lib('parser')->option['indexing']) {
            $fwidth = 1;
            $fheight = 1;
        } else {
    
            // inserted code 2 (~410 line)
            if ($GLOBALS['section_class']=="tiki_wiki_page print"){
                $fwidth = $imageObj->get_width() / 2;
                $fheight = $imageObj->get_height() / 2;
            } else {
                $fwidth = $imageObj->get_width();
                $fheight = $imageObj->get_height();
            }
            // end of inserted code 2 (~638 line)
    
         }
    
    [...]
    

    Now, after printing to pdf by wkhtmltopdf we gets pdf with small but full resolution images.

    Additional modifies:

    • Adds following lines to cms/cssmenus.css (or other css included in print mode) for increase bottom margin of image caption:

      div.thumbcaption {
          margin-bottom: 5mm;
      }
      
    • Removes lines from 171 to ~175 in templates/tiki-show_content.tpl for remove the "The original document is available at" foot.