TCPDF in J4 Topic is solved

This forum is for general questions about extensions for Joomla! 4.x.

Moderators: pe7er, General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10.
Post Reply
neton
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Fri Aug 05, 2022 10:10 pm

TCPDF in J4

Post by neton » Fri Aug 05, 2022 10:19 pm

Hi everybody,
How can i use TCPDF class in joomla 4.
Where must TCPDF files be stored and how include in my component?

Thanx
Last edited by toivo on Sat Aug 06, 2022 1:29 am, edited 1 time in total.
Reason: mod note: moved from 4.x Coding

User avatar
Per Yngve Berg
Joomla! Master
Joomla! Master
Posts: 30809
Joined: Mon Oct 27, 2008 9:27 pm
Location: Romerike, Norway

Re: TCPDF in J4

Post by Per Yngve Berg » Sat Aug 06, 2022 12:31 am


User avatar
toivo
Joomla! Master
Joomla! Master
Posts: 17350
Joined: Thu Feb 15, 2007 5:48 am
Location: Sydney, Australia

Re: TCPDF in J4

Post by toivo » Sat Aug 06, 2022 1:58 am

If you plan to use the TCPDF library to write your own PDF documents, instead of producing Joomla articles as PDF files, use Llewellyn van der Merwe's TCPDF Library.

The JED flags this extension as compatible with J3 but it can be installed also in J4. The TCPDF library itself is stored in libraries/tcpdf.

The attached Proof Of Concept (POC) module was written three years ago to follow Nicola Asuni's documentation at https://tcpdf.org/examples/example_001. The module still works in Joomla 4.1.5 but could be refactored to the latest coding standards and also perhaps display something in the selected module position. At the moment it just creates a file example_001.pdf in the images folder.

mod_pdftest.zip
You do not have the required permissions to view the files attached to this post.
Toivo Talikka, Global Moderator

neton
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Fri Aug 05, 2022 10:10 pm

Re: TCPDF in J4

Post by neton » Thu Aug 11, 2022 1:49 pm

Thankx but Class "Neton\Component\Zmluvy\Administrator\Controller\TCPDF" not found
I used it in my controler:
public function pdf()
{
// Import TCPDF library
jimport('tcpdf.tcpdf');

// create new PDF document
$pdfko = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
}

I think library was not loaded.
What is wrong?

lubo

neton
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Fri Aug 05, 2022 10:10 pm

Re: TCPDF in J4

Post by neton » Sun Aug 14, 2022 3:34 pm

Hi again,
Is it right way to use 'jimport' for loading classes in extensions?
Always class not found :(

Thanks for any help.

chetnath
Joomla! Apprentice
Joomla! Apprentice
Posts: 37
Joined: Tue Dec 18, 2012 2:56 pm

Re: TCPDF in J4

Post by chetnath » Tue Jul 11, 2023 2:36 am

neton wrote:
Thu Aug 11, 2022 1:49 pm
Thankx but Class "Neton\Component\Zmluvy\Administrator\Controller\TCPDF" not found
I used it in my controler:
public function pdf()
{
// Import TCPDF library
jimport('tcpdf.tcpdf');

// create new PDF document
$pdfko = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
}

I think library was not loaded.
What is wrong?

lubo

getting same error..

SharkyKZ
Joomla! Hero
Joomla! Hero
Posts: 2861
Joined: Fri Jul 05, 2013 10:35 am
Location: Parts Unknown

Re: TCPDF in J4

Post by SharkyKZ » Tue Jul 11, 2023 5:38 am

Use fully qualified class name. I.e. import TCPDF class or prefix it with a backslash.

chetnath
Joomla! Apprentice
Joomla! Apprentice
Posts: 37
Joined: Tue Dec 18, 2012 2:56 pm

Re: TCPDF in J4

Post by chetnath » Tue Jul 11, 2023 5:51 am

PFA

class imported but still same issue.
You do not have the required permissions to view the files attached to this post.

SharkyKZ
Joomla! Hero
Joomla! Hero
Posts: 2861
Joined: Fri Jul 05, 2013 10:35 am
Location: Parts Unknown

Re: TCPDF in J4

Post by SharkyKZ » Tue Jul 11, 2023 5:59 am

I don't see the import. Either import the class with use statement:

Code: Select all

use TCPDF;
Or prefix it with a backslash:

Code: Select all

$pdf = new \TCPDF();
https://www.php.net/manual/en/language.namespaces.php

chetnath
Joomla! Apprentice
Joomla! Apprentice
Posts: 37
Joined: Tue Dec 18, 2012 2:56 pm

Re: TCPDF in J4

Post by chetnath » Tue Jul 11, 2023 6:06 am

Thanks
it works with both "use class" and import library.

use \TCPDF;

// Import TCPDF library
jimport('tcpdf.tcpdf');

Thanks


Post Reply

Return to “Extensions for Joomla! 4.x”