Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Constant DOMPDF_ENABLE_REMOTE already defined #4

Closed
jonnywilliamson opened this issue Jul 29, 2013 · 3 comments
Closed

Constant DOMPDF_ENABLE_REMOTE already defined #4

jonnywilliamson opened this issue Jul 29, 2013 · 3 comments

Comments

@jonnywilliamson
Copy link

Hi Barry,

I have probably a fairly unique case here, but I've come up against an issue with this great wrapper for dompdf.

I have some code, that creates a very small pdf using the loadHTML method.

Later on the code needs to call itself again with new variables and tries ones again to create a new Dompdf object and then loadHTML.

On this SECOND attempt of instantiating DOMPDF, I get the above error concerning the already defined constants.

The issue I see is in
/barryvdh/laravel-dompdf/src/Barryvdh/DomPDF/PDF.php

protected function loadConfig(){

        define("DOMPDF_ENABLE_REMOTE", true);
        define("DOMPDF_ENABLE_AUTOLOAD", false);
        define("DOMPDF_CHROOT", base_path());

[....snip....]
    }

If I do a test before defining the constants, everything works perfectly.

 protected function loadConfig(){

       if(!defined("DOMPDF_ENABLE_REMOTE")){
            define("DOMPDF_ENABLE_REMOTE", true);
        }
        if(!defined("DOMPDF_ENABLE_AUTOLOAD")){
            define("DOMPDF_ENABLE_AUTOLOAD", false);
        }
        if(!defined("DOMPDF_CHROOT")){
            define("DOMPDF_CHROOT", base_path());
        }

[....snip....]
}

Would there be any chance of an update to your code so I could update reliably in the future?

Many thanks sir.

@barryvdh
Copy link
Owner

Should be fixed in dev-master.

@barryvdh
Copy link
Owner

Also, do you use the facade or do you instantiate a new PDF object? I thought this issue didn't occur when using the facade, but not really sure.

@jonnywilliamson
Copy link
Author

Actually I hadn't tried using the facade - I was using $pdf = new PDF();

If you want I can try it, but I see you've "fixed" it already so perhaps there's no point now!

Thanks for such a fast response. Much appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants