News:

Looking for documentation? Take a look on our wiki

Main Menu

TCPDF ERROR: The XObject Template '-1' doesn't exist!

Started by thebeuving, May 23, 2015, 00:08:59 AM

Previous topic - Next topic

thebeuving

After upgrading a site to VM 3 and Joomla 3.4 I got this error during checkout or when trying to test generating a sample pdf from the store backend.

It appears that libraries/tcpdf/tcpdf.php sets $header_xobjid to -1, rather than false. But in /components/com_virtuemart/helpers/vmpdf.php there is an if statement around the part that builds the Header template that checks for $this->header_xobjid === false. The same Header function in tcpdf.php that is being overridden does this comparison instead:
if ($this->header_xobjid < 0)

I was able to solve the bug with the following which I think is the correct fix:
In: /components/com_virtuemart/helpers/vmpdf.php on line 252:
replace:
if ($this->header_xobjid === false) {
with:
if ($this->header_xobjid < 0)





Founded in 2005, Khoza Technology, Inc. formerly SRI Hosting, Inc. is an IT services company with proven success building hosted services, applications, and websites.

https://khoza.com

Milbo

Which tcpdf version do you have installed?
Because the -1 is NOT just false!
http://en.wikipedia.org/wiki/Three-valued_logic
http://en.wikipedia.org/wiki/Three-state_logic

Btw, SCNR, that is ternary logic.


if ($this->header_xobj_autoreset) {
// reset header xobject template at each page
$this->header_xobjid = -1;
}


The question is now why we have the -1 here,.....

Okey, it looks like that the -1 was used in  5.9, we have now tcpdf 6. I think the correct fix is to set in vmpdf.php line 337
$this->header_xobjid = false;
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/