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

TCPDF ERROR: Some data has already been output, can't send PDF file #4147

Closed
FI5CHER opened this issue Jun 8, 2018 · 7 comments
Closed

TCPDF ERROR: Some data has already been output, can't send PDF file #4147

FI5CHER opened this issue Jun 8, 2018 · 7 comments

Comments

@FI5CHER
Copy link

FI5CHER commented Jun 8, 2018

Hi.

After update to 9.2 with new remi php i got the following error when i tried to save something as pdf

"TCPDF ERROR: Some data has already been output, can't send PDF file"

No PDF was created, just this error message.

found the solution here
https://stackoverflow.com/questions/16011050/tcpdf-error-some-data-has-already-been-output-cant-send-pdf-file

with a grep i found

grep -r -l -i "pdf->output" 
inc/search.class.php

... and i added a line with "ob_end_clean();" before the lines with "pdf->output"

after adding this the problem was gone .

diff /root/glpi/inc/search.class.php inc/search.class.php
5978a5979
>             ob_end_clean();

PS: just as an info ... the same i did with the glpi-pdf plugin. Maybe you can forward this to "remi" and "yllen" ... because this glpi-pdf plugin is not on github ... :-(

diff /root/pdf/inc/common.class.php plugins/pdf/inc/common.class.php
378a379
>          ob_end_clean();
666c667
< }
\ No newline at end of file
---
> }

 diff /root/pdf/inc/simplepdf.class.php plugins/pdf/inc/simplepdf.class.php 
 139a140
 >       ob_end_clean();
 153a155
 >          ob_end_clean();
 155a158
 >       ob_end_clean();
@trasher
Copy link
Contributor

trasher commented Jun 8, 2018

Try with debug mod disabled.

@FI5CHER
Copy link
Author

FI5CHER commented Jun 8, 2018

debug was disabled. (you mean the bug icon in the right uper corner?)
i tried with debug mode enabled as well ... same behavior .
Interesting was, that pdf creation was working from the dashboard plugin.
i seems that ob_end_clean makes the pdf printing more stable in case that there is something in the buffer ...

@trasher
Copy link
Contributor

trasher commented Jun 8, 2018

Try with debug_mode disabled (always) and all plugins disabled.

@FI5CHER
Copy link
Author

FI5CHER commented Jun 8, 2018

same result.
the system is centos 7 with remi 7.2
with remi 5.6 the problem was also there
the productive system is more or less the same with c7 , glpi 9.1 and php 5.4 . there i dont have the problem.

here some sys infos

[code]
 
GLPI 9.2.3 (/glpi => /data/glpi)
Installation mode: TARBALL

Server

 
Operating system: Linux muc1glpiv01p 3.10.0-862.3.2.el7.x86_64 #1 SMP Mon May 21 23:36:36 UTC 2018 x86_64
PHP 7.2.6 apache2handler (Core, PDO, Phar, Reflection, SPL, SimpleXML, Zend OPcache, apache2handler, apcu, bcmath, bz2,
	calendar, ctype, curl, date, dom, exif, fileinfo, filter, ftp, gd, gettext, hash, iconv, igbinary, imap, intl, json, json_post,
	jsond, ldap, libxml, lzf, mbstring, mcrypt, mysqli, mysqlnd, openssl, pcre, pdo_mysql, pdo_sqlite, posix, session, shmop, snmp,
	soap, sockets, sqlite3, standard, sysvmsg, sysvsem, sysvshm, tidy, tokenizer, wddx, xml, xmlreader, xmlrpc, xmlwriter, xsl, zip,
	zlib)
Setup: max_execution_time="30" memory_limit="128M" post_max_size="8M" safe_mode="" session.save_handler="files"
	upload_max_filesize="2M" 
Software: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.2.6 ()
	Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:60.0) Gecko/20100101 Firefox/60.0
Server Software: MariaDB Server
	Server Version: 10.2.15-MariaDB
	Server SQL Mode: 
	Parameters: glpi@127.0.0.1/glpi
	Host info: 127.0.0.1 via TCP/IP
	
mysqli extension is installed
ctype extension is installed
fileinfo extension is installed
json extension is installed
mbstring extension is installed
zlib extension is installed
curl extension is installed
gd extension is installed
simplexml extension is installed
xml extension is installed
ldap extension is installed
imap extension is installed
Zend OPcache extension is installed
APCu extension is installed
xmlrpc extension is installed
OK/data/glpi/config : OK
OK/data/glpi/files : OK
OK/data/glpi/files/_dumps : OK
OK/data/glpi/files/_sessions : OK
OK/data/glpi/files/_cron : OK
OK/data/glpi/files/_graphs : OK
OK/data/glpi/files/_lock : OK
OK/data/glpi/files/_plugins : OK
OK/data/glpi/files/_tmp : OK
OK/data/glpi/files/_cache : OK
OK/data/glpi/files/_rss : OK
OK/data/glpi/files/_uploads : OK
OK/data/glpi/files/_pictures : OK
OK/data/glpi/files/_log : OK
Web access to the files directory should not be allowed but this cannot be checked automatically on this instance.
Make sure acces to error log file is forbidden; otherwise review .htaccess file and web server configuration.OKSELinux mode is Disabled

Libraries

 
htmLawed version 1.2.4 in (/data/glpi/lib/htmlawed)
phpCas version 1.3.5 in (/data/glpi/vendor/jasig/phpcas/source)
PHPMailer version 5.2.26 in (/data/glpi/vendor/phpmailer/phpmailer)
SimplePie version 1.5.1 in (/data/glpi/vendor/simplepie/simplepie/library)
TCPDF version 6.2.16 in (/data/glpi/vendor/tecnickcom/tcpdf)
michelf/php-markdown in (/data/glpi/vendor/michelf/php-markdown/Michelf)
true/punycode in (/data/glpi/vendor/true/punycode/src)
iacaml/autolink in (/data/glpi/vendor/iamcal/lib_autolink)
sabre/vobject in (/data/glpi/vendor/sabre/vobject/lib)

LDAP directories

 
Server: 'xxxxx', Port: '389', BaseDN: 'xxxx', Connection filter:
		'xxx.... '


SQL replicas

 
Not active

Notifications

 
Way of sending emails: SMTP (anonymous@localhost)

Mails receivers

 
Name: 'glpi@xxxx....' Active: Yes
	Server: '{xxxx..../imap}' Login: 'glpi' Password: Yes

Plugins list

 
	accounts             Name: Accounts                       Version: 2.3.2      State: Not activated
	fields               Name: Additionnal fields             Version: 1.7.2      State: Not activated
	news                 Name: Alerts                         Version: 1.3.5      State: Not activated
	appliances           Name: Appliances                     Version: 2.3.2      State: Not activated
	financialreports     Name: Asset situation                Version: 2.4.1      State: Not activated
	badges               Name: Badges                         Version: 2.3.0      State: Not activated
	barcode              Name: Barcode                        Version: 2.1.0      State: Not activated
	positions            Name: Cartography                    Version: 4.4.0      State: Not activated
	certificates         Name: Certificates                   Version: 2.3.0      State: Not activated
	connections          Name: Connections                    Version: 9.2        State: Not activated
	consumables          Name: Consumable request             Version: 1.3.1      State: Not activated
	credit               Name: Credit vouchers                Version: 1.1.1      State: Not activated
	dashboard            Name: Dashboard                      Version: 0.9.2      State: Not activated
	databases            Name: Databases                      Version: 2.0.0      State: Not activated
	domains              Name: Domains                        Version: 1.9.0      State: Not activated
	environment          Name: Environment                    Version: 2.1.0      State: Not activated
	escalade             Name: Escalation                     Version: 2.2.2      State: Not activated
	datainjection        Name: File injection                 Version: 2.5.1      State: Not activated
	formvalidation       Name: Form Validation                Version: 0.2.3      State: Not activated
	formcreator          Name: Forms                          Version: 2.6.3      State: Not activated
	fusioninventory      Name: FusionInventory                Version: 9.2+2.0    State: Not activated
	openvas              Name: GLPi openvas Connector         Version: 1.1.0      State: Not activated
	resources            Name: Human Resources                Version: 2.4.3      State: Not activated
	geninventorynumber   Name: Inventory number generation    Version: 2.2.0      State: Not activated
	mailanalyzer         Name: Mail Analyzer                  Version: 1.3.8      State: Not activated
	mreporting           Name: More Reporting                 Version: 1.4.0      State: Not activated
	satisfaction         Name: More satisfaction              Version: 1.2.1      State: Not activated
	moreticket           Name: More ticket                    Version: 1.3.3      State: Not activated
	mydashboard          Name: My Dashboard                   Version: 1.5.0      State: Not activated
	nebackup             Name: nebackup                       Version: 2.2.1      State: Not activated
	archires             Name: Network Architectures          Version: 2.5.1      State: Not activated
	genericobject        Name: Objects management             Version: 2.5.1      State: Not activated
	order                Name: Orders management              Version: 2.0.1      State: Not activated
	pdf                  Name: Print to pdf                   Version: 1.3.1.1    State: Not activated
	printercounters      Name: Printer counters               Version: 1.4.0      State: Not activated
	processmaker         Name: Process Maker                  Version: 3.2.8      State: Not activated
	purgelogs            Name: Purge history                  Version: 1.3.0      State: Not activated
	racks                Name: Rack enclosures management     Version: 1.8.0      State: Not activated
	reports              Name: Reports                        Version: 1.11.3     State: Not activated
	seasonality          Name: Seasonalities                  Version: 1.3.0      State: Not activated
	shellcommands        Name: Shell Commands                 Version: 2.1.0      State: Not activated
	manufacturersimports Name: Suppliers imports              Version: 2.0.0      State: Not activated
	surveyticket         Name: Survey                         Version: 9.2+1.1    State: Not activated
	tag                  Name: Tag Management                 Version: 2.1.1      State: Not activated
	tasklists            Name: Tasks list                     Version: 1.2.0      State: Not activated
	timezones            Name: Timezones                      Version: 2.2.0      State: Not installed
	typology             Name: Typologies                     Version: 2.4.0      State: Not activated
	webapplications      Name: Web applications               Version: 2.4.0      State: Not activated

@trasher
Copy link
Contributor

trasher commented Jul 2, 2018

I cannot reproduce on 9.3 (tested on demo website and local).

@FI5CHER
Copy link
Author

FI5CHER commented Jul 2, 2018

hi "trasher"

i don't want you to reproduce this error and i don't need any help.

i just recommend to add an

ob_end_clean();

before every

$pdf->Output('glpi.pdf', 'I');

in any file where tcpdf is used by glpi , that's all.

ob_end_clean cleans the output buffer . So if some messages are in this buffer , tcpdf creates this error message ...
and to avoid this errors it's recommended to use

ob_end_clean(); $pdf->Output('glpi.pdf', 'I');

instead of a simple

$pdf->Output('glpi.pdf', 'I');

see http://php.net/manual/en/function.ob-end-clean.php and https://stackoverflow.com/questions/16011050/tcpdf-error-some-data-has-already-been-output-cant-send-pdf-file

for some reasons under centos 7 and glpi 9.2 it's not working without ob_end_clean .

@Gambware
Copy link

Thats work for me ! Thanks

@glpi-project glpi-project locked as resolved and limited conversation to collaborators Jun 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants