Title: dompdf integration
Last modified: August 31, 2022

---

# dompdf integration

 *  [Haja](https://wordpress.org/support/users/hajakutbudeen/)
 * (@hajakutbudeen)
 * [3 years, 9 months ago](https://wordpress.org/support/topic/dompdf-integration/)
 * Hello there,
 * I want to convert html template into pdf, for that i need dompdf.
 * I download that from github ([https://github.com/dompdf/dompdf/releases/download/v2.0.0/dompdf_2-0-0.zip](https://github.com/dompdf/dompdf/releases/download/v2.0.0/dompdf_2-0-0.zip))
   extract that and upload into child theme section.
 * In functions.php added following code for testing
 *     ```
       add_action( 'wp_footer', 'temp' );
       function temp(){
       	include_once( get_stylesheet_directory() .'/dompdf/autoload.inc.php');
       	use Dompdf\Dompdf;
       	define('DOMPDF_UNICODE_ENABLED', true);
       	$dompdf = new Dompdf();
       	$dompdf->load_html("<h1>Hello World</h1><p>PDF description</p>");
       	$dompdf->setPaper('A4','potrait');
       	$dompdf->render();
       	$dompdf->stream('title.pdf');
       }
       ```
   
 * When i reload my page its shown error There has been a critical error on this
   website.
 * please advise.

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

 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [3 years, 9 months ago](https://wordpress.org/support/topic/dompdf-integration/#post-15968372)
 * If you’re able to rename the HTML file with a .pdf extension, you don’t really
   need dompdf. But you may use it if you prefer.
 * Anyway, when you get that critical error message, you need to check your server’s
   error log to learn what the actual error was so you can take corrective action.
 * While you’re developing new code, it’s a minor hassle to check the log every 
   time any error is introduced. (I tend to make a lot of errors). I like to define`
   WP_DEBUG` as `true` in wp-config.php. Right below that definition, add this line:
   `
   define( 'WP_DISABLE_FATAL_ERROR_HANDLER', true );` With those changes, error 
   messages will appear right on the page, no need to go looking for the error log.
   Don’t leave things this way on a production site (set both to `false` for production),
   visible error messages can be leveraged by hackers to gain useful knowledge about
   your site.
 *  Thread Starter [Haja](https://wordpress.org/support/users/hajakutbudeen/)
 * (@hajakutbudeen)
 * [3 years, 9 months ago](https://wordpress.org/support/topic/dompdf-integration/#post-15969170)
 * Hey,
 * Actually i want convert customer invoice email to pdf thats why i need dompdf
   lib, i added those lines in wp-config which is you mentioned, there’s not error
   highlighted, i checked server side error cause on code
 * use Dompdf\Dompdf;
 * so there’s no error in first line include_once( get_stylesheet_directory() .’/
   dompdf/autoload.inc.php’); next line trigger issue
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [3 years, 9 months ago](https://wordpress.org/support/topic/dompdf-integration/#post-15970667)
 * Namespace declarations must be [the very first thing in a PHP file](https://www.php.net/manual/en/language.namespaces.definition.php),
   right after the initial `<?php`. Your dompdf code needs to be in its own file,
   which you can then include or require from elsewhere.

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

The topic ‘dompdf integration’ is closed to new replies.

## Tags

 * [dompdf](https://wordpress.org/support/topic-tag/dompdf/)

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 3 replies
 * 2 participants
 * Last reply from: [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * Last activity: [3 years, 9 months ago](https://wordpress.org/support/topic/dompdf-integration/#post-15970667)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
