VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: santille on December 23, 2013, 15:30:24 PM

Title: Virtuemart tcpdf library
Post by: santille on December 23, 2013, 15:30:24 PM
Hello,

Here is my configuration : Joomla 2.5.16, Template Shop and Buy, Virtuemart 2.0.26 last version.
Installed the last tcpdf library.
I've the following message when I try to generate an invoice from an order : "Fatal error: Call to undefined method VmVendorPDF::convertHTMLColorToDec() in /.../components/com_virtuemart/helpers/vmpdf.php on line 112"
I found some forum posted answers but nothing really to explain a solution.

Somebody has an explanation?

Thanks for your help.

seb
Title: Re: Virtuemart tcpdf library
Post by: Milbo on December 26, 2013, 21:44:32 PM
sorry no clue
Title: Re: Virtuemart tcpdf library
Post by: reinhold on December 26, 2013, 22:08:30 PM
It appears that the TCPDF developers thought it was a good idea to change their API and factor some functions out of the TCPDF class into some dedicated helper classes (TCPDF_COLOR in this case)...

http://www.tcpdf.org/doc/code/classTCPDF__COLORS.html#a6fe7c8360e8226aea52fd44068f1b6b9

The changelog on the TCPDF homepage says:

6.0.000 (2013-03-17)
- IMPORTANT: PHP4 support has been removed starting from this version.
- Several TCPDF methods and vars were moved to new class files: tcpdf_static.php, tcpdf_colors.php, tcpdf_images.php, tcpdf_font_data.php, tcpdf_fonts.php.
- Files htmlcolors.php, spotcolors.php, unicode_data.php and ecodings_maps.php were removed.


So, you can either use a TCPDF version <6.0 with VirtueMart, or you can install the latest TCPDF version, but need to modify that line 112 of vmpdf.php to use the TCPDF_COLORS::convertHTMLColorToDec function instead of $this->convertHTMLColorToDec.

Unfortunately, VirtueMart cannot be changed to support versions <6.0 and versions >6.0 of TCPDF at the same time... (did I mention that I hate API changes...)

Reinhold
Title: Re: Virtuemart tcpdf library
Post by: Milbo on December 26, 2013, 22:22:46 PM
But we can use for vm2.2 the new API, right?
Title: Re: Virtuemart tcpdf library
Post by: reinhold on December 26, 2013, 22:28:45 PM
Sure, we can update our included copy of TCPDF to a version >=6.0.
I have, however, not tried it out at all. I just searched for that function that triggered the error and found that they have a new release... Maybe there are more API-incompatibilities.

Also, in VM we have to make sure somehow that our included copy is preferred over any joomla-wide installed copy. AFAIK, some other extensions also ship their own copy of TCPDF, so the wrong version (from a different extension) might be loaded in that case... But that's the same problem whether we upgrade to version 6.0 or not.
Somehow reminds me of Windows DLL hell.

Reinhold
Title: Re: Virtuemart tcpdf library
Post by: chaldama on February 05, 2014, 20:51:58 PM
Will this issue be solved in an upcoming release?
Right now I just diabled PDf invoicing but this is not a real solution.
Title: Re: Virtuemart tcpdf library
Post by: Milbo on February 06, 2014, 12:46:01 PM
Quote from: reinhold on December 26, 2013, 22:08:30 PM
So, you can either use a TCPDF version <6.0 with VirtueMart, or you can install the latest TCPDF version, but need to modify that line 112 of vmpdf.php to use the TCPDF_COLORS::convertHTMLColorToDec function instead of $this->convertHTMLColorToDec.

Unfortunately, VirtueMart cannot be changed to support versions <6.0 and versions >6.0 of TCPDF at the same time... (did I mention that I hate API changes...)

Reinhold

Why not using a check, if the new file is there, if the file is there use TCPDF_COLORS::, else $this->
Title: Re: Virtuemart tcpdf library
Post by: chaldama on February 06, 2014, 14:45:04 PM
I do not know what to check and when you make changes to core Virtuemart files you'll have to check this with every update?
Title: Re: Virtuemart tcpdf library
Post by: Milbo on February 07, 2014, 19:14:08 PM
No chaldama, i mean a check, which I write one time in it, so that people like you dont have to care about.
Title: Re: Virtuemart tcpdf library
Post by: chaldama on February 07, 2014, 19:43:28 PM
I feel really stupid but I just don't understand what I should do to solve this issue permanently.
Title: Re: Virtuemart tcpdf library
Post by: Milbo on February 08, 2014, 20:14:49 PM
Try this file in \components\com_virtuemart\helpers, replace the vmpdf.php

just for people intersted, the code

$tcpdf6 = JFile::exists(JPATH_VM_LIBRARIES.DS.'tcpdf'.DS.'include'.DS.'tcpdf_color.php');
if($tcpdf6){
$vlfooterlcolor = TCPDF_COLORS::convertHTMLColorToDec($this->vendor->vendor_letter_footer_line_color);
} else {
$vlfooterlcolor = $this->convertHTMLColorToDec($this->vendor->vendor_letter_footer_line_color);
}

$this->setHeaderData(($this->vendor->vendor_letter_header_image?$this->vendorImage:''),
     ($this->vendor->vendor_letter_header_image?$this->vendor->vendor_letter_header_imagesize:0),
     '', $this->vendor->vendor_letter_header_html, array(0,0,0),$vlfooterlcolor );


[attachment cleanup by admin]