PHP Errors, just after altering PDF template/Show HTML in Description field

Update: So I have found that I edited out a function in the template file because I wanted the Item Description to render out HTML tags that I have in the description field. So I altered:

<?php echo nl2br(htmlsc($item->item_description)); ?>

to be:

<?php echo nl2br($item->item_description); ?>

and this causes the errors. If I have htmlsc($item->item_description) it shows HTML tags in that field, for example ul and li tags instead of dots for an unordered list. Is there some way I can have this?

Hello everyone,

Today I noticed my quote template needed updating since I installed 1.5.9 recently. I altered my v1.5.9 pdf template file (as I noticed it was a bit different to my previous one after I just copied that version over) and it generated a couple of times fine, then after some edits of the quote and i tried to regenerate the PDF I got some PHP errors:

#### A PHP Error was encountered

Severity: Notice

Message: Undefined index: direction

Filename: src/Mpdf.php

Line Number: 13448

Backtrace:

File: /home/beardedd/public_html/ip159/vendor/mpdf/mpdf/src/Mpdf.php
Line: 13448
Function: _error_handler

File: /home/beardedd/public_html/ip159/vendor/mpdf/mpdf/src/Mpdf.php
Line: 23767
Function: TableHeaderFooter

File: /home/beardedd/public_html/ip159/vendor/mpdf/mpdf/src/Tag/Table.php
Line: 1121
Function: _tableWrite

File: /home/beardedd/public_html/ip159/vendor/mpdf/mpdf/src/Tag.php
Line: 246
Function: close

File: /home/beardedd/public_html/ip159/vendor/mpdf/mpdf/src/Mpdf.php
Line: 15216
Function: CloseTag

File: /home/beardedd/public_html/ip159/application/helpers/mpdf_helper.php
Line: 96
Function: WriteHTML

File: /home/beardedd/public_html/ip159/application/helpers/pdf_helper.php
Line: 259
Function: pdf_create

File: /home/beardedd/public_html/ip159/application/modules/quotes/controllers/Quotes.php
Line: 193
Function: generate_quote_pdf

File: /home/beardedd/public_html/ip159/index.php
Line: 325
Function: require_once
---
#### A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /home/beardedd/public_html/ip159/vendor/codeigniter/framework/system/core/Exceptions.php:271)

Filename: core/Common.php

Line Number: 564

Backtrace:
---
#### An uncaught Exception was encountered

Type: Mpdf\MpdfException

Message: Data has already been sent to output, unable to output PDF file

Filename: /home/beardedd/public_html/ip159/vendor/mpdf/mpdf/src/Mpdf.php

Line Number: 9292

Backtrace:

File: /home/beardedd/public_html/ip159/application/helpers/mpdf_helper.php
Line: 127
Function: Output

File: /home/beardedd/public_html/ip159/application/helpers/pdf_helper.php
Line: 259
Function: pdf_create

File: /home/beardedd/public_html/ip159/application/modules/quotes/controllers/Quotes.php
Line: 193
Function: generate_quote_pdf

File: /home/beardedd/public_html/ip159/index.php
Line: 325
Function: require_once

I get a few more errors like this further down the page that loads.

A few pieces of information:

I am using PHP 7.1 on the invoiceplane directory.
I installed v1.5.9 as a clean install, not over the top of an older version, and have been using it for a month or so I’d guess.
I have not copied any old files over to the new 1.5.9 installation, I only just did that today to get some extra pdf quote templates.
Everything else in IP 1.5.9 seems to be working perfectly for me.
I get that there’s a problem with the MPdf.php file but I’d rather ask here first to see if anyone knows what I should do. I’m happy to update specific files etc.

My webhost says I am running close to using all of my inode quota, I have used 138076/150000 of it. I have about 2Gb of free disk space left on the account, so I guess its not space. Could the inode usage be a problem?

Sorry if the formatting of this message is no good, I coudln’t find a preview option before I posted

Could be a lot places to search, but mPDF is very sensible to correct formating!
So pls check you HTML and you CSS to be valid and check if you closed all tags and if you use formating mPDF supports.

Example of an HTML attribute: <div align="center">

mPDF supports attribute values in single or double quotes e.g. <div align="center"> or <div align='center'>

Minimised attributes are not supported e.g. <input type="checkbox" disabled />

XHTML specification is recommended for best compliance with mPDF.

Check all supported HTML Tags LINK

Anyway I noticed that IP sometimes falls back to the last working PDF-Template if the latest edits failed. So pls check all of your latest changes to be supported.

Did you try to modify any headers?

You will get that message if your aplication outputs some text to the browser before rending your HTML page. For example. a misplaced “echo …” or an error message can cause this.

1 Like

Thanks for the tips guys. If it was unclear, I edited my original message with an update and I found it was because I only removed a call to function htmlsc() in the PDF template.

I checked the mPDF supported HTML that Martin provided the link for and the HTML I am trying to include only uses ul, /ul, li and /li tags which are all supported by mPDF.

I’m not a PHP expert, but I think htmlsc() converts HTML special entities to their HTML codes so that, for example a greater than symbol, is displayed on the page instead of being considered as the start of a HTML tag. This is what I don’t want applied to the $item->description field. I want to be able to put HTML in the description and have it rendered on the PDF by mPDF. The previous version of IP would do this for me, so seems like the 1.5.x series is different in this aspect.

v1.4 and v1.5 do have big differences.
Pls try to stick with the “new standard template” copy it and modify it to fit your needs. Hope this will then show where the error was/is.

Hi,

Today I went to generate another quote PDF and am getting errors again.

The default PDF template file works fine, but I want an altered version that hides the discount, item prices and item totals on my quotes.

So I decided to remove ALL of my altered code from my modified template and I am still getting mPDF errors. I have put the two files into an online diff checker, and I can’t see any reason why mPDF would fail up based on what I’ve done to the template file. I’ve literally brought it to the point that I have just some placeholder HTML comment tags in the file where I wanted my altered code and it’s STILL generating errors and failures.

See the two files compared here: https://www.diffchecker.com/BCg9xG0w

The left is the default template, the right is my modified file with, now, only placeholder comment tags. There is still something wrong with this file and it generates error output as described above in the original post.

Here are the errors this template file has generated, in their entirety (only replaced my account username in the errors):

A PHP Error was encountered
Severity: Notice

Message: Undefined index: direction

Filename: src/Mpdf.php

Line Number: 13448

Backtrace:

File: /home/myUsername/public_html/ip159/vendor/mpdf/mpdf/src/Mpdf.php
Line: 13448
Function: _error_handler

File: /home/myUsername/public_html/ip159/vendor/mpdf/mpdf/src/Mpdf.php
Line: 23767
Function: TableHeaderFooter

File: /home/myUsername/public_html/ip159/vendor/mpdf/mpdf/src/Tag/Table.php
Line: 1121
Function: _tableWrite

File: /home/myUsername/public_html/ip159/vendor/mpdf/mpdf/src/Tag.php
Line: 246
Function: close

File: /home/myUsername/public_html/ip159/vendor/mpdf/mpdf/src/Mpdf.php
Line: 15216
Function: CloseTag

File: /home/myUsername/public_html/ip159/application/helpers/mpdf_helper.php
Line: 96
Function: WriteHTML

File: /home/myUsername/public_html/ip159/application/helpers/pdf_helper.php
Line: 259
Function: pdf_create

File: /home/myUsername/public_html/ip159/application/modules/quotes/controllers/Quotes.php
Line: 193
Function: generate_quote_pdf

File: /home/myUsername/public_html/ip159/index.php
Line: 325
Function: require_once

A PHP Error was encountered
Severity: Notice

Message: Undefined index: cellLineHeight

Filename: src/Mpdf.php

Line Number: 13461

Backtrace:

File: /home/myUsername/public_html/ip159/vendor/mpdf/mpdf/src/Mpdf.php
Line: 13461
Function: _error_handler

File: /home/myUsername/public_html/ip159/vendor/mpdf/mpdf/src/Mpdf.php
Line: 23767
Function: TableHeaderFooter

File: /home/myUsername/public_html/ip159/vendor/mpdf/mpdf/src/Tag/Table.php
Line: 1121
Function: _tableWrite

File: /home/myUsername/public_html/ip159/vendor/mpdf/mpdf/src/Tag.php
Line: 246
Function: close

File: /home/myUsername/public_html/ip159/vendor/mpdf/mpdf/src/Mpdf.php
Line: 15216
Function: CloseTag

File: /home/myUsername/public_html/ip159/application/helpers/mpdf_helper.php
Line: 96
Function: WriteHTML

File: /home/myUsername/public_html/ip159/application/helpers/pdf_helper.php
Line: 259
Function: pdf_create

File: /home/myUsername/public_html/ip159/application/modules/quotes/controllers/Quotes.php
Line: 193
Function: generate_quote_pdf

File: /home/myUsername/public_html/ip159/index.php
Line: 325
Function: require_once

A PHP Error was encountered
Severity: Notice

Message: Undefined index: cellLineStackingStrategy

Filename: src/Mpdf.php

Line Number: 13462

Backtrace:

File: /home/myUsername/public_html/ip159/vendor/mpdf/mpdf/src/Mpdf.php
Line: 13462
Function: _error_handler

File: /home/myUsername/public_html/ip159/vendor/mpdf/mpdf/src/Mpdf.php
Line: 23767
Function: TableHeaderFooter

File: /home/myUsername/public_html/ip159/vendor/mpdf/mpdf/src/Tag/Table.php
Line: 1121
Function: _tableWrite

File: /home/myUsername/public_html/ip159/vendor/mpdf/mpdf/src/Tag.php
Line: 246
Function: close

File: /home/myUsername/public_html/ip159/vendor/mpdf/mpdf/src/Mpdf.php
Line: 15216
Function: CloseTag

File: /home/myUsername/public_html/ip159/application/helpers/mpdf_helper.php
Line: 96
Function: WriteHTML

File: /home/myUsername/public_html/ip159/application/helpers/pdf_helper.php
Line: 259
Function: pdf_create

File: /home/myUsername/public_html/ip159/application/modules/quotes/controllers/Quotes.php
Line: 193
Function: generate_quote_pdf

File: /home/myUsername/public_html/ip159/index.php
Line: 325
Function: require_once

A PHP Error was encountered
Severity: Notice

Message: Undefined index: cellLineStackingShift

Filename: src/Mpdf.php

Line Number: 13463

Backtrace:

File: /home/myUsername/public_html/ip159/vendor/mpdf/mpdf/src/Mpdf.php
Line: 13463
Function: _error_handler

File: /home/myUsername/public_html/ip159/vendor/mpdf/mpdf/src/Mpdf.php
Line: 23767
Function: TableHeaderFooter

File: /home/myUsername/public_html/ip159/vendor/mpdf/mpdf/src/Tag/Table.php
Line: 1121
Function: _tableWrite

File: /home/myUsername/public_html/ip159/vendor/mpdf/mpdf/src/Tag.php
Line: 246
Function: close

File: /home/myUsername/public_html/ip159/vendor/mpdf/mpdf/src/Mpdf.php
Line: 15216
Function: CloseTag

File: /home/myUsername/public_html/ip159/application/helpers/mpdf_helper.php
Line: 96
Function: WriteHTML

File: /home/myUsername/public_html/ip159/application/helpers/pdf_helper.php
Line: 259
Function: pdf_create

File: /home/myUsername/public_html/ip159/application/modules/quotes/controllers/Quotes.php
Line: 193
Function: generate_quote_pdf

File: /home/myUsername/public_html/ip159/index.php
Line: 325
Function: require_once

A PHP Error was encountered
Severity: Notice

Message: Undefined index: direction

Filename: src/Mpdf.php

Line Number: 13448

Backtrace:

File: /home/myUsername/public_html/ip159/vendor/mpdf/mpdf/src/Mpdf.php
Line: 13448
Function: _error_handler

File: /home/myUsername/public_html/ip159/vendor/mpdf/mpdf/src/Mpdf.php
Line: 23767
Function: TableHeaderFooter

File: /home/myUsername/public_html/ip159/vendor/mpdf/mpdf/src/Tag/Table.php
Line: 1121
Function: _tableWrite

File: /home/myUsername/public_html/ip159/vendor/mpdf/mpdf/src/Tag.php
Line: 246
Function: close

File: /home/myUsername/public_html/ip159/vendor/mpdf/mpdf/src/Mpdf.php
Line: 15216
Function: CloseTag

File: /home/myUsername/public_html/ip159/application/helpers/mpdf_helper.php
Line: 96
Function: WriteHTML

File: /home/myUsername/public_html/ip159/application/helpers/pdf_helper.php
Line: 259
Function: pdf_create

File: /home/myUsername/public_html/ip159/application/modules/quotes/controllers/Quotes.php
Line: 193
Function: generate_quote_pdf

File: /home/myUsername/public_html/ip159/index.php
Line: 325
Function: require_once

A PHP Error was encountered
Severity: Notice

Message: Undefined index: cellLineHeight

Filename: src/Mpdf.php

Line Number: 13461

Backtrace:

File: /home/myUsername/public_html/ip159/vendor/mpdf/mpdf/src/Mpdf.php
Line: 13461
Function: _error_handler

File: /home/myUsername/public_html/ip159/vendor/mpdf/mpdf/src/Mpdf.php
Line: 23767
Function: TableHeaderFooter

File: /home/myUsername/public_html/ip159/vendor/mpdf/mpdf/src/Tag/Table.php
Line: 1121
Function: _tableWrite

File: /home/myUsername/public_html/ip159/vendor/mpdf/mpdf/src/Tag.php
Line: 246
Function: close

File: /home/myUsername/public_html/ip159/vendor/mpdf/mpdf/src/Mpdf.php
Line: 15216
Function: CloseTag

File: /home/myUsername/public_html/ip159/application/helpers/mpdf_helper.php
Line: 96
Function: WriteHTML

File: /home/myUsername/public_html/ip159/application/helpers/pdf_helper.php
Line: 259
Function: pdf_create

File: /home/myUsername/public_html/ip159/application/modules/quotes/controllers/Quotes.php
Line: 193
Function: generate_quote_pdf

File: /home/myUsername/public_html/ip159/index.php
Line: 325
Function: require_once

A PHP Error was encountered
Severity: Notice

Message: Undefined index: cellLineStackingStrategy

Filename: src/Mpdf.php

Line Number: 13462

Backtrace:

File: /home/myUsername/public_html/ip159/vendor/mpdf/mpdf/src/Mpdf.php
Line: 13462
Function: _error_handler

File: /home/myUsername/public_html/ip159/vendor/mpdf/mpdf/src/Mpdf.php
Line: 23767
Function: TableHeaderFooter

File: /home/myUsername/public_html/ip159/vendor/mpdf/mpdf/src/Tag/Table.php
Line: 1121
Function: _tableWrite

File: /home/myUsername/public_html/ip159/vendor/mpdf/mpdf/src/Tag.php
Line: 246
Function: close

File: /home/myUsername/public_html/ip159/vendor/mpdf/mpdf/src/Mpdf.php
Line: 15216
Function: CloseTag

File: /home/myUsername/public_html/ip159/application/helpers/mpdf_helper.php
Line: 96
Function: WriteHTML

File: /home/myUsername/public_html/ip159/application/helpers/pdf_helper.php
Line: 259
Function: pdf_create

File: /home/myUsername/public_html/ip159/application/modules/quotes/controllers/Quotes.php
Line: 193
Function: generate_quote_pdf

File: /home/myUsername/public_html/ip159/index.php
Line: 325
Function: require_once

A PHP Error was encountered
Severity: Notice

Message: Undefined index: cellLineStackingShift

Filename: src/Mpdf.php

Line Number: 13463

Backtrace:

File: /home/myUsername/public_html/ip159/vendor/mpdf/mpdf/src/Mpdf.php
Line: 13463
Function: _error_handler

File: /home/myUsername/public_html/ip159/vendor/mpdf/mpdf/src/Mpdf.php
Line: 23767
Function: TableHeaderFooter

File: /home/myUsername/public_html/ip159/vendor/mpdf/mpdf/src/Tag/Table.php
Line: 1121
Function: _tableWrite

File: /home/myUsername/public_html/ip159/vendor/mpdf/mpdf/src/Tag.php
Line: 246
Function: close

File: /home/myUsername/public_html/ip159/vendor/mpdf/mpdf/src/Mpdf.php
Line: 15216
Function: CloseTag

File: /home/myUsername/public_html/ip159/application/helpers/mpdf_helper.php
Line: 96
Function: WriteHTML

File: /home/myUsername/public_html/ip159/application/helpers/pdf_helper.php
Line: 259
Function: pdf_create

File: /home/myUsername/public_html/ip159/application/modules/quotes/controllers/Quotes.php
Line: 193
Function: generate_quote_pdf

File: /home/myUsername/public_html/ip159/index.php
Line: 325
Function: require_once

A PHP Error was encountered
Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /home/myUsername/public_html/ip159/vendor/codeigniter/framework/system/core/Exceptions.php:271)

Filename: core/Common.php

Line Number: 564

Backtrace:

An uncaught Exception was encountered
Type: Mpdf\MpdfException

Message: Data has already been sent to output, unable to output PDF file

Filename: /home/myUsername/public_html/ip159/vendor/mpdf/mpdf/src/Mpdf.php

Line Number: 9292

Backtrace:

File: /home/myUsername/public_html/ip159/application/helpers/mpdf_helper.php
Line: 127
Function: Output

File: /home/myUsername/public_html/ip159/application/helpers/pdf_helper.php
Line: 259
Function: pdf_create

File: /home/myUsername/public_html/ip159/application/modules/quotes/controllers/Quotes.php
Line: 193
Function: generate_quote_pdf

File: /home/myUsername/public_html/ip159/index.php
Line: 325
Function: require_once