I have an external php file that contains the code to generate pdf using DOMPDF. I needed to access WordPress built-in functions in that file. So, by following this link here, I included the following line:
require_once(plugins_url().'/../../wp-load.php');
Now, I am able to call WP functions, but the generated pdf is broken i.e I get "error trying to open the pdf..".
If I comment out the require_once line, the pdf comes out fine. Any ideas why this might happen?