Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8906773
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:44:25+00:00 2026-06-15T02:44:25+00:00

How can I make dompdf work with a Symfony 2.1 project? I followed this

  • 0

How can I make dompdf work with a Symfony 2.1 project?
I followed this TUTORIAL but I’m still getting this exception:

Notice: Use of undefined constant DOMPDF_LIB_DIR – assumed
‘DOMPDF_LIB_DIR’ in
[blablabla]/vendor/dino/dompdf/lib/DOMPDF/stylesheet.cls.php
line 16

if not this, what is the best and simplest library to create pdf from html with Symfony 2.1 ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T02:44:26+00:00Added an answer on June 15, 2026 at 2:44 am

    Here is what I’ve done to make DOMPDF available to me in a Symfony2 project:

    1. require the DinoPDF composer package:
      php composer.phar require dino/dompdf, version 0.1.1 (or dev-master)

    2. DomPDF init files need to be required() somewhere in the loading process:

      • copy the vendor/dino/dompdf/dompdf_config.inc.php.dist to app/dompdf_config.inc.php
      • copy the vendor/dino/dompdf/dompdf_config.custom.inc.php.dist to app/dompdf_config.custom.inc.php
      • add in your app/autoload.php:

        require_once __DIR__.'/dompdf_config.inc.php';
        

    dompdf_config.inc.php defines the paths to your DOMpdf installation. DinoPDF distribution changed the paths within the library, so this has to be taken care of:

    DOMPDF_INC_DIR: Main DOMPdf classes. In dinoPDF distribution of DOMPdf this folder is renamed from dompdf/include to dompdf/lib/DOMPDF

    DOMPDF_LIB_DIR: Additional resources – fonts, etc. In dinoPDF distribution of DOMPdf this folder is renamed from dompdf/lib to dompdf/lib/vendor

    Here are the changes I’ve introduced to dompdf_config.inc.php:

    /**
     * The root of your DOMPDF installation
     */
    define("DOMPDF_DIR", str_replace(DIRECTORY_SEPARATOR, '/',                     realpath(__DIR__.'/../vendor/dino/dompdf/')));
    /**
     * The location of the DOMPDF include directory
     * Main DOMPdf classes
     * In dinoPDF distribution of DOMPdf this folder is renamed from dompdf/include to     dompdf/lib/DOMPDF
     */
    define("DOMPDF_INC_DIR", DOMPDF_DIR . "/lib/DOMPDF");
    
    /**
     * The location of the DOMPDF lib directory
     * Additional resources - fonts, etc.
     * In dinoPDF distribution of DOMPdf this folder is renamed from dompdf/lib to     dompdf/lib/vendor
     */
    define("DOMPDF_LIB_DIR", DOMPDF_DIR . "/lib/vendor");
    
    /** Include the custom config file if it exists */
    if ( file_exists(__DIR__ . "/dompdf_config.custom.inc.php") ){
        require_once(__DIR__ . "/dompdf_config.custom.inc.php");
    }
    
    def("DOMPDF_FONT_DIR", DOMPDF_LIB_DIR . "/fonts/");
    

    This should correctly include the library, so that it could be used in controllers, for ex. like this:

    /**
     * @Route("/export_pdf", name="export_pdf")
     */
    public function exportPDFAction($id)
    {   
        $html =
        '<html><body>'.
        '<p>Put your html here, or generate it with your favourite '.
        'templating system.</p>'.
        '</body></html>';
    
        $dompdf = new \DOMPDF();
        $dompdf->load_html($html);
        $dompdf->render();
    
        $response = new Response();
    
        $response->setContent($dompdf->output());
        $response->setStatusCode(200);
        $response->headers->set('Content-Type', 'application/pdf');
    
        return $response;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got good code, it used do work. But now I can't make it
I can make a new , and that seems to work. But edit/update does
I can make a obj to use the canvas to draw like this: MyObj.myDiv
I can make it work this way Dir.chdir(basedir) puts Dir.glob(#{filename}*).inspect Is there any way
How I can make Student class serializable? I'm reading this article but I do
How can make custom Exception Handling on objective C... Any useful tutorial please guide
I can make this list by hand: list( list(n=1) , list(n=2), list(n=3) ) But
I can make this code work without an object as input parameter for the
How can I make jsTree hide non-matching elements, but still display the subnodes of
I can make a single row IKImageBrowserView by setting the [imageBrowser setContentResizingMask:NSViewWidthSizable]; but in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.