Title: Fatal: must be of type Countable|array, string given
Last modified: May 2, 2025

---

# Fatal: must be of type Countable|array, string given

 *  [mtg169](https://wordpress.org/support/users/mtg169/)
 * (@mtg169)
 * [11 months, 3 weeks ago](https://wordpress.org/support/topic/fatal-must-be-of-type-countablearray-string-given/)
 * Seeing the following fatal on multiple sites as `$psName` is a string instead
   of an array as shown in fatal.
 *     ```wp-block-code
       PHP Fatal error:  Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, string given in /srv/htdocs/wp-content/plugins/pdf-print/mpdf/classes/ttfontsuni.php:613Stack trace:#0 /srv/htdocs/wp-content/plugins/pdf-print/mpdf/classes/ttfontsuni.php(202): TTFontFile->extractInfo(false, true, 255)#1 /srv/htdocs/wp-content/plugins/pdf-print/mpdf/mpdf.php(3880): TTFontFile->getMetrics('/srv/htdocs/wp-...', 'dejavusansmono', 0, false, true, 255)#2 /srv/htdocs/wp-content/plugins/pdf-print/mpdf/mpdf.php(4246): mPDF->AddFont('dejavusansmono', '')#3 /srv/htdocs/wp-content/plugins/pdf-print/mpdf/mpdf.php(13624): mPDF->SetFont('dejavusansmono')#4 /srv/htdocs/wp-content/plugins/pdf-print/mpdf/mpdf.php(1287): mPDF->SetDefaultFont('dejavusansmono')#5 /srv/htdocs/wp-content/plugins/pdf-print/pdf-print.php(1398): mPDF->__construct('', 'A4', 11.0, 'dejavusansmono', 15, 15, 16, 16)#6 /wordpress/core/6.8.1/wp-includes/class-wp-hook.php(324): pdfprnt_print(Object(WP))#7 /wordpress/core/6.8.1/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array)#8 /wordpress/core/6.8.1/wp-includes/plugin.php(565): WP_Hook->do_action(Array)#9 /wordpress/core/6.8.1/wp-includes/class-wp.php(835): do_action_ref_array('wp', Array)#10 /wordpress/core/6.8.1/wp-includes/functions.php(1342): WP->main('')#11 /wordpress/core/6.8.1/wp-blog-header.php(16): wp()#12 /wordpress/core/6.8.1/index.php(17): require('/wordpress/core...')#13 {main}  thrown in /srv/htdocs/wp-content/plugins/pdf-print/mpdf/classes/ttfontsuni.php on line 613
       ```
   
 * Related code:
   `**for** ($i = 0; $i < count($psName); $i++)`Can you please add
   better data type handling or use strlen instead of count if it should be a string?

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

 *  Plugin Support [andrewsupport](https://wordpress.org/support/users/andrewsupport/)
 * (@andrewsupport)
 * [11 months, 2 weeks ago](https://wordpress.org/support/topic/fatal-must-be-of-type-countablearray-string-given/#post-18455963)
 * Hi,
 * The error is related to mPDF library, we do not change the content of library
   code. Please try to update mPDF library on the settings page and let us know 
   the result.
 *  Thread Starter [mtg169](https://wordpress.org/support/users/mtg169/)
 * (@mtg169)
 * [11 months, 2 weeks ago](https://wordpress.org/support/topic/fatal-must-be-of-type-countablearray-string-given/#post-18460128)
 * We attempted to update in the settings on one site that was throwing fatals as
   a test and it appears to have deleted the mpdf directory from the plugin entirely
   and downloaded to wp-content/uploads/vendor. Is that expected? 
   If so, is there
   a reason plugin updates are including an outdated version of mPDF directly in
   the plugin’s codebase that cause fatals? PHP 7.4 has been end of life and no 
   longer maintained since 2022-11-28.
 * We host millions of WordPress sites and it would be a tedious process to login
   to each and update the settings in the plugin. If you can update the library 
   in the plugin directly to a newer version, it would be helpful.
 *  Plugin Support [andrewsupport](https://wordpress.org/support/users/andrewsupport/)
 * (@andrewsupport)
 * [11 months, 1 week ago](https://wordpress.org/support/topic/fatal-must-be-of-type-countablearray-string-given/#post-18472163)
 * Hi,
 * Thank you for the clarification.
 * Yes, the plugin includes an option to update to the latest mPDF version via the
   settings page, and it’s expected behavior that the updated library is downloaded
   to `wp-content/uploads/vendor/`.
 * However, we understand your concern. Currently, the plugin includes an older 
   version of mPDF by default to ensure backward compatibility, but this version
   may not be fully compatible with PHP 8+. We’re actively considering **bundling
   the latest mPDF version by default** in a future update to avoid manual steps,
   especially in large-scale environments like yours.
 * In the meantime:
    - We recommend updating mPDF via plugin settings on any sites using PHP 8+ to
      avoid such fatal errors.
    - We’re also reviewing the codebase to improve **data type handling** in case
      outdated files are still being used.
 * Thanks again for your helpful feedback — it’s extremely valuable for improving
   the plugin in real-world scenarios.

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

The topic ‘Fatal: must be of type Countable|array, string given’ is closed to new
replies.

 * ![](https://ps.w.org/pdf-print/assets/icon-256x256.gif?rev=2580392)
 * [PDF & Print by BestWebSoft - WordPress Posts and Pages PDF Generator Plugin](https://wordpress.org/plugins/pdf-print/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/pdf-print/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/pdf-print/)
 * [Active Topics](https://wordpress.org/support/plugin/pdf-print/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/pdf-print/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/pdf-print/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [andrewsupport](https://wordpress.org/support/users/andrewsupport/)
 * Last activity: [11 months, 1 week ago](https://wordpress.org/support/topic/fatal-must-be-of-type-countablearray-string-given/#post-18472163)
 * Status: not resolved