• A new version of Full Calendar is now available.

    See the details here

PDF output

  • Views Views: 37,188
  • Last updated Last updated:
  • Docu is work in progress.

    Installation/ Activation​

    Since Fabrik 4.2 the libaries are separated again.
    You must download and install the libarary package before you can run PDF.
    See https://fabrikar.com/fabrik-base-infos

    For setting up PDF output:
    Go to Fabrik "Options" (button upper right on every Fabrik backend site).
    In the "Global" tab select your prefered PDF library.
    In "Debugging" tab: Debug PDF has to be NO
    In "List" and "Form" tab: you can choose global settings for showing the PDF button (can also be set individually in list and form "Layout" settings )
    In "List" tab you can enable "Allow PDF Localhost" and "Allow PDF IP" if you are running into issues with access settings (see tooltips for details)

    3rd party compatibility​

    Plugin System - Flexisystem, core functions: make sure "Redirect pdf format" is set to NO.
    https://fabrikar.com/forums/index.php?wiki/admintools/#joomla-feature-hardening-options

    Settings​

    PDF Options can be set in list and form settings ("Layout" section)
    PDFSettings.PNG

    The PDF icon has also global Options in Fabrik "Options".

    PDF templates​

    The standard templates can be used, but is recommended to create custom PDF templates.
    To create a custom template, copy the templates folder and rename it. Template locations are as follows:
    • Joomla 4+: Details: components/com_fabrik/views/details/tmpl/ (PDF template is always a details template)
    • Joomla 4+: List: components/com_fabrik/views/list/tmpl/
    Dompdf has issues in rendering e.g. float and boxes, in a custom template you can adapt the CSS settings to your needs. It's advisable to add background and/or border for testing to see what PDF libs are doing.
    Use your browser dev console to inspect the CSS classes.

    CSS example details view​

    To get labels left you can add or modify your custom CSS File.

    Code:
    /*domPDF, J! Bootstrap5 template*/
    #$form .row {position:relative;display:block; page-break-inside: avoid; padding:.6rem}
    #$form .col-sm-2 {display:inline-block;width:16%;vertical-align:top;}
    #$form .col-sm-3 {display:inline-block;width:24%;vertical-align:top;}
    #$form .col-sm-4 {display:inline-block;width:32%;vertical-align:top;}
    #$form .col-sm-5 {display:inline-block;width:40%;vertical-align:top;}
    #$form .col-sm-6 {display:inline-block;width:48%;vertical-align:top;}
    #$form .col-sm-7 {display:inline-block;width:56%;vertical-align:top;}
    #$form .col-sm-8 {display:inline-block;width:64%;vertical-align:top;}
    #$form .col-sm-9 {display:inline-block;width:72%;vertical-align:top;}
    #$form .col-sm-10 {display:inline-block;width:80%;vertical-align:top;}
    #$form .col-sm-11 {display:inline-block;width:88%;vertical-align:top;}
    #$form .col-sm-12 {display:inline-block;width:96%;vertical-align:top;}
    /*May be for image display*/
    #{$form} img {width:auto;height:auto;}
    To display yes/no (domPDF standard fonts don't support the IcoMoon icons)
    Code:
    #{$form} .icon-checkmark:before {content:'yes'}
    #{$form} .icon-remove:before {content:'no'}

    CSS example list div template
    Code:
    #listform_$c .fabrikList .row-fluid .span4 {display:inline-block;width:26%;float:none;}
    #listform_$c .fabrikList .row-fluid {page-break-inside:avoid;}

    domPDF template with page header, footer and pagenumber​

    Create a custom template.
    Edit default.php (this example is referring to a copy of fabrik list Bootstrap template):
    Below line "defined('_JEXEC') or die('Restricted access');" add
    Code:
    ?>
    <div id="footdompdf">
    <span class="footleft"><?php echo $this->table->label;?></span>
    <span class="pagenum">Page </span>
    </div>
    <div id="headerdompdf">
    <span class="headleft"><?php echo $this->table->label;?></span>
    <span class="pdfdate">19-11-2013</span>
    </div>
    <?php

    Create/edit custom_css.php
    Add CSS
    Code:
    body {margin-top:1.5em;margin-bottom:1.5em}
    #headerdompdf {
    display:block;
    position: fixed;
    top: 0px;
    width:100%;
    height:1.1em;
    border-bottom: 1px solid red;
    }
    #footdompdf {
    display:block;
    position: fixed;
    bottom: 0px;
    width:100%;
    height: 1.1em;
    border-top: 1px solid red;
    }
    #footdompdf .pagenum { position:absolute;
    right: 20px;}
    #footdompdf .pagenum:after {
    content: counter(page) ; //This is including the page number at bottom right
    }
    #footdompdf .footleft {
    color:red;
    }

    domPDF with total pages​

    See https://fabrikar.com/forums/index.php?threads/dompdf-page-x-of-y.54274/

    mPDF template with page header, footer and pagenumber​

    See also https://mpdf.github.io/headers-footers/method-4.html
    Create a custom template.
    Edit default.php (this example is referring to a copy of fabrik list Bootstrap template):
    Below line "defined('_JEXEC') or die('Restricted access');" add
    Code:

    ?>
    <style>
    @page {size:auto;
    margin-top:3cm;margin-bottom:3cm;

    odd-header-name: html_MyHeader1;
    odd-footer-name: html_MyFooter1;
    }
    .fabrikDataContainer table {page-break-inside:auto;width:100%;}

    </style>
    <htmlpageheader name="MyHeader1">
    <div style="text-align: right; border-bottom: 1px solid #000000; font-weight: bold; font-size: 10pt;">My document {DATE j-m-Y}</div>
    </htmlpageheader>
    <htmlpagefooter name="MyFooter1">
    <table width="100%">
    <tr>
    <td width="33%">{DATE j-m-Y}</td>
    <td width="33%" align="center">{PAGENO}/{nbpg}</td>
    <td width="33%" style="text-align: right; ">My document</td>
    </tr>
    </table>
    </htmlpagefooter>
    <?php

    Additionally replace <tfoot> </tfoot> tags (navigation around line 71/ 77 resp. calculation around line 118/136) with <tbody> </tbody>

    PDF fonts, UTF-8 characters​

    Dompdf uses it's own fonts included in (as of Fabrik 3.8) libraries/fabrik/vendor/dompdf/dompdf/lib/fonts. Only the dejavu fonts support UTF-8 characters.

    To force the PDF output to use DejaVu, put this in a custom_css.php in your template folder:
    Code:

    * {font-family:'dejavu sans'!important}

    Too include a custom font in a pdf details view, you can add the following:

    Code:

    @font-face {
    font-family: 'yourfontname';
    font-style: normal;
    font-weight: normal;
    src: url('https://websitedomain/subfoldername/yourfontname.ttf) format('truetype');
    }

    Filter Values​

    Filter values are in
    $this->filters['table___element']->displayValue
    e.g. for a date range filter
    Code:
    echo $this->filters['test___date_time']->displayValue;
    will give something like
    2020-07-15 16:30:36, 2021-07-22 16:30:36

    Activate PHP Mode​

    in libraries\fabrik\fabrik\fabrik\Helpers\Pdf.php line 143 add
    Code:
    $Options->set("isPhpEnabled", true);


    Open domPDF in new Tab instead Download​

    Edit file : libraries/fabrik/vendor/dompdf/dompdf/src/Adapter/CPDF.php changed these lines:

    From
    Code:
    if (!isset($Options["Attachment"])) $Options["Attachment"] = true;

    to:

    Code:
     $Options["Attachment"] = false;

    and

    From
    Code:
     $attachment = $Options["Attachment"] ? "attachment" : "inline";

    To:

    Code:
     $attachment = "inline";

    Set name of PDF file​

    $this->doc->setName('your-file-name-without-pdf-extension');
Back
Top