Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Contributor Ewout

    (@pomegranate)

    Hello Mindmaker,
    DomPDF has not been abandoned, although admittedly the last commit is 4 months ago, this is about the same for mpdf. Both libraries have their own limitations and merits.
    The DomPDF authors are usually quick to respond to issues and if there are big problems I am sure they will help.

    Switching libraries is not something that is without risk, especially considering the fact that many people have custom templates and not everything works the same (just like cross browser CSS compatibility, only much worse…).

    I may include an option to switch to another PDF library in the future, but I’m currenly focussing on getting better documentation and better plugin stability.

    I will contact the people behind DomPDF and ask them if there are any plans of integrating the total page numbers without inline PHP.

    Ewout

    Thread Starter m1ndmaker

    (@m1ndmaker)

    You are right, the DomPDF version on github has a 4 months old last commit. In some of the forum entries they wrote, they would include a total number of pages fix in 0.6. What version are you using? I could not find a version number in any of the DomPDF lib phps…?

    I do understand the problems involved when switching the library. However, an invoice generation plugin without the capability of displaying the total number of pages is, simply put, more than disappointing.

    Best

    Michael

    Plugin Contributor Ewout

    (@pomegranate)

    Hello Michael,
    I am using 0.6 with the latest security fixes, I believe this release is from june last year. They don’t keep a proper version log though ??

    I have emailed the guys from DOMPDF and asked them about implementing the page count. Meanwhile we’ll have to do with regular page numbers without the total count…

    <style>.pagenum:before { content: counter(page); }</style>
    Page: <span class="pagenum"></span>

    Thread Starter m1ndmaker

    (@m1ndmaker)

    Thanks Ewout,

    Meanwhile I built in the total number of pages using inline PHP. A CSS statement like counter(pages) would be the ideal solution.

    In case someone can make use of the code, the following prints the total number of pages to the bottom center of the current page (inline PHP has to be enabled).

    <script type="text/php">
      if ( isset($pdf) ) {
        $pdf->page_script('
          if ($PAGE_COUNT > 1) {
            $font = Font_Metrics::get_font("Arial", "normal");
            $size = 7;
            $pageText = "Page " . $PAGE_NUM . " of " . $PAGE_COUNT;
            $y = $pdf->get_height() - 80;
            $x = ($pdf->get_width() - Font_Metrics::get_text_width($pageText, $font, $size) ) / 2 ;
            $pdf->text($x, $y, $pageText, $font, $size);
          }
        ');
      }
    </script>

    It is quite important to have a total number of pages on a document like an invoice. Our current customer insisted to include it, and it is actually a fair point as invoices are being used for tax verifying and VAT reporting.

    Best

    Michael

    Plugin Contributor Ewout

    (@pomegranate)

    Thanks for sharing Michael!
    To complete the instructions, you can enable inline PHP by adding the following code to your themes functions.php (changes it in the plugin will get overwritten on updates):

    define("DOMPDF_ENABLE_PHP", true);

    I’ll update this thread when DOMPDF gets this feature.

    Have a great day!
    Ewout

    Hi,

    I am using the google cloud print plugin, and have order sent to the printer, can i ask what file do you add the code to, as have tried functions php, plugin template files and header with no joy, have also enabled the inline function.

    I have a different static file associated with each base product in a composite product. Each element of the composite product has an associated PDF file name store in a custom field.When an order is placed
    I want to be able to pass the custom field value for each of these elements into static file fields on the PDF invoices & packing PRO version so that the name of each product element ordered and their associated PDF file name is emailed to another departmenet.

    Is this possible?

    oops sorry I posted in wrong place

    Plugin Contributor Ewout

    (@pomegranate)

    Hi Carosea,
    Since you’re using the professional extension, I have emailed you a tailored solution ??

    As for the original thread: with the latest version of the plugin, you can add page numbers by adding this to your template:

    {{PAGE_NUM}} / {{PAGE_COUNT}}

    The plugin will then replace this with the actual page number and total page count when the document is created.

    Ewout

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘DomPDF usage’ is closed to new replies.