kchuying
kchuying

Reputation: 83

Drupal 7: Print pdf using dompdf

I need help in installation of dompdf. Where should I place the extracted zip file in the directory? I've followed the INSTALL.txt, and it says "Extract the contents of the downloaded package into one of the supported paths." Does it mean placing into "Modules" folder? if so, an error occurs requesting for ".info". And it's not supplied. Please help, I'm confused! Thanks!

Upvotes: 4

Views: 2776

Answers (2)

learningtech
learningtech

Reputation: 33715

here's how I loaded it

  • I moved the folder dompdf-0.5.1 to the /sites/all/libraries folder
  • I edited dompdf_config.inc.php by replacing the DOMPDF_autoload() function with:

Code:

function DOMPDF_autoload($class) {
  /* Add this checking - START */
  if (mb_strtolower($class)== 'firephp'){
    return;
  }
  /* Add this checking - END */

  $filename = mb_strtolower($class) . ".cls.php";
  require_once(DOMPDF_INC_DIR . "/$filename");
}
if ( !function_exists("__autoload") ) {
  /**
   * Default __autoload() function
   *
   * @param string $class
   */
  function __autoload($class) {
    DOMPDF_autoload($class);
  }
}
  • now you should be able use it like so in any other module

Code:

    require_once(realpath('.')."/sites/all/libraries/dompdf-0.5.1/dompdf_config.inc.php");
    spl_autoload_register('DOMPDF_autoload'); 

    $obj = new DOMPDF();

This worked and I was able to use the DOMPDF object/class.

Upvotes: 1

jsheffers
jsheffers

Reputation: 1622

The supported paths are listed in the install.txt file:

supported paths:
  * print module lib directory (usually sites/all/modules/print/lib)
  * libraries directory (sites/all/libraries)

I prefer the second option, it will keep you from having to do this every time you update the module.

In other words it should look like this sites/all/libraries/dompdf

Upvotes: 1

Related Questions