Title: DomPDF usage
Last modified: August 22, 2016

---

# DomPDF usage

 *  Resolved [m1ndmaker](https://wordpress.org/support/users/m1ndmaker/)
 * (@m1ndmaker)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/dompdf-usage/)
 * Do you intend switching to another project like mPDF ([http://www.mpdf1.com/mpdf/index.php](http://www.mpdf1.com/mpdf/index.php))
   in the near future? DomPDF has been abandoned for years now. The fix to include
   a total number of pages using inline PHP is actually a pretty dirty one. mPDF
   offers this out of the box.
 * As we are using the Pro version of the plugin, we would appreciate a future version
   built on a more reliable and cleaner implementation of a PDF creation routine.
 * Thank you and kind regards
 * [https://wordpress.org/plugins/woocommerce-pdf-invoices-packing-slips/](https://wordpress.org/plugins/woocommerce-pdf-invoices-packing-slips/)

Viewing 9 replies - 1 through 9 (of 9 total)

 *  Plugin Contributor [Ewout](https://wordpress.org/support/users/pomegranate/)
 * (@pomegranate)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/dompdf-usage/#post-5934904)
 * Hello Mindmaker,
    DomPDF has not been abandoned, although admittedly the [last commit](https://github.com/dompdf/dompdf/commits/develop)
   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](https://wordpress.org/support/users/m1ndmaker/)
 * (@m1ndmaker)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/dompdf-usage/#post-5934932)
 * 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](https://wordpress.org/support/users/pomegranate/)
 * (@pomegranate)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/dompdf-usage/#post-5935109)
 * 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](https://wordpress.org/support/users/m1ndmaker/)
 * (@m1ndmaker)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/dompdf-usage/#post-5935118)
 * 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](https://wordpress.org/support/users/pomegranate/)
 * (@pomegranate)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/dompdf-usage/#post-5935121)
 * 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
 *  [Chrisra](https://wordpress.org/support/users/chrisra/)
 * (@chrisra)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/dompdf-usage/#post-5935461)
 * 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.
 *  [carosea](https://wordpress.org/support/users/carosea/)
 * (@carosea)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/dompdf-usage/#post-5935466)
 * 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?
 *  [carosea](https://wordpress.org/support/users/carosea/)
 * (@carosea)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/dompdf-usage/#post-5935467)
 * oops sorry I posted in wrong place
 *  Plugin Contributor [Ewout](https://wordpress.org/support/users/pomegranate/)
 * (@pomegranate)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/dompdf-usage/#post-5935470)
 * 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.

 * ![](https://ps.w.org/woocommerce-pdf-invoices-packing-slips/assets/icon-256x256.
   png?rev=2189942)
 * [PDF Invoices & Packing Slips for WooCommerce](https://wordpress.org/plugins/woocommerce-pdf-invoices-packing-slips/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce-pdf-invoices-packing-slips/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce-pdf-invoices-packing-slips/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce-pdf-invoices-packing-slips/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce-pdf-invoices-packing-slips/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce-pdf-invoices-packing-slips/reviews/)

## Tags

 * [dompdf](https://wordpress.org/support/topic-tag/dompdf/)
 * [invoices](https://wordpress.org/support/topic-tag/invoices/)
 * [mPDF](https://wordpress.org/support/topic-tag/mpdf/)
 * [pagination](https://wordpress.org/support/topic-tag/pagination/)
 * [pdf](https://wordpress.org/support/topic-tag/pdf/)
 * [total number](https://wordpress.org/support/topic-tag/total-number/)

 * 9 replies
 * 4 participants
 * Last reply from: [Ewout](https://wordpress.org/support/users/pomegranate/)
 * Last activity: [10 years, 2 months ago](https://wordpress.org/support/topic/dompdf-usage/#post-5935470)
 * Status: resolved