Custom template error on download PDF - "Cannot modify header information - headers already sent"

I’m trying to use custom fonts in a template (testing on localhost wordpress).
If i try adding a css import inside the header tag, I get 8 warnings
“Cannot modify header information - headers already sent”, one for each of the header lines in
class-mainwp-pro-reports-pdf.php
Why can that be?

@amaau can you please post the custom template file for us to investigate it for you?

Sure, here it is.
It’s just the default template with a css import, if i remove that single line everything works.
I actually want to import a local css file with local fonts, but to be safe I test with this import since it’s what another user on this forum used without issues.

EDIT
To potentially save some time, here’s the community system report


### Server Info                    Required                                               Detected                                     Status   ###

MainWP Dashboard                   
MainWP Dashboard Version           4.1.10.1                                               4.1.10.1                                     Pass        
MainWP Upload Directory            Writable                                               Writable                                     Pass        
MainWP Extensions                  
Advanced Uptime Monitor Extension  5.2                                                    API License Active                           Pass        
MainWP White Label Extension       4.1                                                    API License Active                           Pass        
MainWP Client Reports Extension    4.0.9                                                  API License Active                           Pass        
MainWP Google Analytics Extension  4.0.3.2                                                API License Active                           Pass        
MainWP Maintenance Extension       4.1                                                    API License Active                           Pass        
MainWP Page Speed Extension        4.0.1.1                                                API License Active                           Pass        
MainWP Pro Reports Extension       4.0.6                                                  API License Active                           Pass        
MainWP Sucuri Extension            4.0.8.1                                                API License Active                           Pass        
WordPress                          
WordPress Version                  >=3.6                                                  5.8.1                                        Pass        
WordPress Memory Limit             >=64M                                                  40M                                          Warning     
MultiSite Disabled                 =true                                                  true                                         Pass        
FileSystem Method                  = direct                                               direct                                       Pass        
PHP                                
PHP Version                        >=7.0                                                  7.3.32                                       Pass        
PHP Safe Mode Disabled             =true                                                  true                                         Pass        
PHP Max Execution Time             >=30 seconds                                           120                                          Pass        
PHP Max Input Time                 >=30 seconds                                           120                                          Pass        
PHP Memory Limit                   >=128M                                                 768M                                         Pass        
PCRE Backtracking Limit            >=10000                                                1000000                                      Pass        
PHP Upload Max Filesize            >=2M                                                   256M                                         Pass        
PHP Post Max Size                  >=2M                                                   256M                                         Pass        
SSL Extension Enabled              =true                                                  true                                         Pass        
SSL Warnings                       = empty                                                                                             Pass        
cURL Extension Enabled             =true                                                  true                                         Pass        
cURL Timeout                       >=300 seconds                                          40                                           Warning     
cURL Version                       >=7.18.1                                               7.66.0                                       Pass        
cURL SSL Version                   >=OpenSSL/1.1.0                                        OpenSSL/1.1.1l-fips                          Pass        
PHP Allow URL fopen                YES                                                    
PHP Exif Support                   YES ( V7.3.)                                           
PHP IPTC Support                   YES                                                    
PHP XML Support                    YES                                                    
PHP Disabled Functions             No functions disabled.                                 
PHP Loaded Extensions              Core, PDO, Phar, Reflection, SPL, SimpleXML, Zend OPcache, apache2handler, bcmath, bz2, calendar, ctype, curl, date, dba, dom, enchant, exif, fileinfo, filter, ftp, gd, gettext, gmp, hash, iconv, imap, intl, json, libxml, mbstring, memcached, mysqli, mysqlnd, openssl, pcre, pdo_mysql, pdo_pgsql, pdo_sqlite, pgsql, posix, pspell, session, shmop, soap, sockets, sodium, sqlite3, standard, sysvmsg, sysvsem, tidy, tokenizer, wddx, xml, xmlreader, xmlrpc, xmlwriter, xsl, zip, zlib
MySQL                              
MySQL Version                      >=5.0                                                  5.7.32-35-log                                Pass        
MySQL Mode                         NO_ENGINE_SUBSTITUTION                                 
MySQL Client Encoding              utf8                                                   
Server Info                        
Server Software                    Apache                                                 
Operating System                   Linux                                                  
Architecture                       64		 bit                                               
Server Protocol                    HTTP/1.0                                               
HTTPS                              ON                                                     
Server self connect                Response Test O.K.                                     
User Agent                         Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36
Gateway Interface                  CGI/1.1                                                
Memory Usage                       52.34 MB                                               
Request Time                       1636211839                                             
Accept Content                     text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Accept-Charset Content             N/A                                                    
MainWP Settings                    
Number Of Child Sites              2                                                      
Use WP-Cron                        No                                                     
Optimize for Shared Hosting or Big NetworksNo                                                     
Automatic Daily Update             Install trusted updates                                
Abandoned Plugins/Themes Tolerance                                                        
Maximum number of posts to return                                                         
Maximum number of pages to return                                                         
Primary Backup System              Default MainWP Backups                                 
Maximum simultaneous requests      4                                                      
Minimum delay between requests     200                                                    
Maximum simultaneous requests per ip1                                                      
Minimum delay between requests to the same ip1000                                                   
Maximum simultaneous sync requests                                                        
Maximum simultaneous install and update requests                                                       
Active Plugins                     
Complianz Privacy Suite (GDPR/CCPA) premium5.4.0.2                                                Inactive                                     
Duplicate Page                     4.4.5                                                  Active                                       
Duplicator                         1.4.3                                                  Active                                       
Ele Custom Skin                    3.1.3                                                  Active                                       
Ele Custom Skin Pro                3.1.0                                                  Active                                       
Elementor                          3.4.7                                                  Active                                       
Elementor Pro                      3.4.2                                                  Active                                       
JetElements For Elementor          2.5.9                                                  Inactive                                     
JetEngine                          2.9.4                                                  Inactive                                     
JetSmartFilters                    2.3.2                                                  Inactive                                     
MainWP Dashboard                   4.1.10.1                                               Active                                       
SiteGround Optimizer               6.0.1                                                  Active                                       
SiteGround Security                1.1.3                                                  Active                                       

I got a message from your spam filter Akismet, that my post was temporarily hidden.
I suspect it’s because i’ve updated the link to the template file, because I noticed that file.io deleted it so I uploaded it again.

@amaau Sorry about that - i just looked up a fast way to share a file here. I guess drop box would be a more permanent way. I have downloaded your file.io link though just in case it goes bad again…

Please give me time to go over this today - thank you very much for your patience.

Ok, thank you (min 20 char limit)

1 Like

@amaau SOrry about the delay here!

I tested out your template and also in a new copy and I can not replicate the issue that you are describing - the PDF generates just fine.

Is your system completely updated?

Also, there has been another thread with a work around with this that might solve your issue if it’s what is causing it. Google fonts and custom Pro Report templates

@kwcjr
Hi!
True, I’ve been playing around with many things and at some point the problem went away.
There are still issues with how dom2pdf handles custom fonts and some css rules, but if I’ll get stuck there I’ll start another post.
Thank you

@amaau Yeaaah I can attest to domPDF being quite a paint in the butt to work with too. I noticed that MainWP does package a fonts folder within /uploads - font might be able to be “Installed” in order to work correctly. But this needs to be looked into to to say otherwise.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.