Hi,
I developed a component, which stores content in its own tables, not in Joomla's #__content table. I got a request from a client to save the displayed text into pdf.
I decided to use Phoca PDF for this purpose because of its flexibility and configurability. So I created new plugin for Phoca PDF to provide bridge to my component. For the simple cases everything works fine.
What I mean by simple cases:
- html text only
- html text and image files
In some cases I need to display generated images. I mean I use PHP GD2 library to draw images, for example charts. PDF cannot be displayed with these generated images. In IE I get the following error message: "TCPDF ERROR: [Image] Unable to get image."
Have you ever bumped into this problem or something similar?
Do you have experince with TCPDF and GD2 compatibility?
Any other suggestion is welcome. Thanks.
TCPDF and GD2 compatibility
-
- Phoca Member
- Posts: 19
- Joined: 22 Feb 2009, 00:10
- Location: Hungary
- Contact:
-
- Phoca Member
- Posts: 19
- Joined: 22 Feb 2009, 00:10
- Location: Hungary
- Contact:
Re: TCPDF and GD2 compatibility
I found the solution to my problem. I share it with you, it may help someone.
When I generate images with GD2 functions, their HTML-code looks like this: (browsers can display them)
TCPDF can display GD2-generated images in a PDF-file, if their code looks like this:
So I had to put string-replace function into the code of my plugin:
And it works like a charm.
When I generate images with GD2 functions, their HTML-code looks like this: (browsers can display them)
Code: Select all
<img src="data:image/png;base64,#some_encrypted_code_here#" />
Code: Select all
<img src="@#some_encrypted_code_here#" />
Code: Select all
$myHtmlContent = $document->getBuffer();
$myHtmlContent = str_replace("data:image/png;base64,", "@", $myHtmlContent);
$pdf->writeHTML($myHtmlContent, true);
- Jan
- Phoca Hero
- Posts: 48403
- Joined: 10 Nov 2007, 18:23
- Location: Czech Republic
- Contact:
Re: TCPDF and GD2 compatibility
Hi, thank you very much for the guide.
Jan
Jan
If you find Phoca extensions useful, please support the project