TCPDF in J4 Topic is solved
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.
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.
-
- Joomla! Fledgling
- Posts: 3
- Joined: Fri Aug 05, 2022 10:10 pm
TCPDF in J4
Hi everybody,
How can i use TCPDF class in joomla 4.
Where must TCPDF files be stored and how include in my component?
Thanx
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
Reason: mod note: moved from 4.x Coding
- Per Yngve Berg
- Joomla! Master
- Posts: 30809
- Joined: Mon Oct 27, 2008 9:27 pm
- Location: Romerike, Norway
- toivo
- Joomla! Master
- Posts: 17350
- Joined: Thu Feb 15, 2007 5:48 am
- Location: Sydney, Australia
Re: TCPDF in J4
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.
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.
You do not have the required permissions to view the files attached to this post.
Toivo Talikka, Global Moderator
-
- Joomla! Fledgling
- Posts: 3
- Joined: Fri Aug 05, 2022 10:10 pm
Re: TCPDF in J4
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
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
-
- Joomla! Fledgling
- Posts: 3
- Joined: Fri Aug 05, 2022 10:10 pm
Re: TCPDF in J4
Hi again,
Is it right way to use 'jimport' for loading classes in extensions?
Always class not found
Thanks for any help.
Is it right way to use 'jimport' for loading classes in extensions?
Always class not found
Thanks for any help.
-
- Joomla! Apprentice
- Posts: 37
- Joined: Tue Dec 18, 2012 2:56 pm
Re: TCPDF in J4
neton wrote: ↑Thu Aug 11, 2022 1:49 pmThankx 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..
-
- Joomla! Hero
- Posts: 2861
- Joined: Fri Jul 05, 2013 10:35 am
- Location: Parts Unknown
Re: TCPDF in J4
Use fully qualified class name. I.e. import TCPDF class or prefix it with a backslash.
-
- Joomla! Apprentice
- Posts: 37
- Joined: Tue Dec 18, 2012 2:56 pm
Re: TCPDF in J4
PFA
class imported but still same issue.
class imported but still same issue.
You do not have the required permissions to view the files attached to this post.
-
- Joomla! Hero
- Posts: 2861
- Joined: Fri Jul 05, 2013 10:35 am
- Location: Parts Unknown
Re: TCPDF in J4
I don't see the import. Either import the class with use statement:
Or prefix it with a backslash:
https://www.php.net/manual/en/language.namespaces.php
Code: Select all
use TCPDF;
Code: Select all
$pdf = new \TCPDF();
-
- Joomla! Apprentice
- Posts: 37
- Joined: Tue Dec 18, 2012 2:56 pm
Re: TCPDF in J4
Thanks
it works with both "use class" and import library.
use \TCPDF;
// Import TCPDF library
jimport('tcpdf.tcpdf');
Thanks
it works with both "use class" and import library.
use \TCPDF;
// Import TCPDF library
jimport('tcpdf.tcpdf');
Thanks