0

I tried to convert my CodeIgniter 3 file to pdf with this Dompdf library: https://github.com/iamfiscus/Codeigniter-DOMPDF

Got few errors but already fixed it from this github source: https://github.com/dompdf/dompdf/tree/981c1b977fbc78eeb5bc6f1e4cc3ae217b6a65d2/src/Frame

Yet there's still one error message that says like this:

A PHP Error was encountered
Severity: Compile Error

Message: Could not check compatibility between FrameList::getIterator(): FrameListIterator and IteratorAggregate::getIterator(): Traversable, because class FrameListIterator is not available

Filename: include/frame.cls.php

Line Number: 850

Backtrace:

Here's my source code in frame.cls.php within Dompdf library (line 833-854):

class FrameList implements IteratorAggregate {
  /**
   * @var Frame
   */
  protected $_frame;

  /**
   * @param Frame $frame
   */
  function __construct($frame)
  {
      $this->_frame = $frame;
  }

  /**
   * @return FrameListIterator
   */
// code below is line 850:
  function getIterator(): FrameListIterator
  {
      return new FrameListIterator($this->_frame);
  }
}

Is there any way I can fix this without updating/changing the dompdf version? cause I'm a beginner coder, yet it's hard for me to resolve a library problem.

N.B: I'm manually put the library in my codeigniter, not using composer.

I already tried to find solution from many websites and video tutorials, but it's not working for me. So, I'm really hoping that anyone can get me a solution for the frame.cls.php file.

whileiam
  • 1
  • 1
  • 1
    You started out with code that's 12 years old. That's not a great start. It then seems you tried to fiddle that code by adding in newer bits? As a general rule of thumb you should never use outdated code or change 3th party code. I can understand your reluctance to use composer, but you're in luck. If you [read the DomPDF page carefully](https://github.com/dompdf/dompdf#download-and-install) you'll see that there's an easy way to install it without composer. – KIKO Software Feb 20 '23 at 10:16
  • @KIKOSoftware I read it. So I guess I have to use composer for newer version then? do you have more detailed guide about how to use the package with composer in CodeIgniter 3? Thanks for the advice anyway, appreciate it. – whileiam Feb 20 '23 at 13:00
  • No, you can download the latest version of DomPDF and use it _without_ Composer, as per the instructions I pointed out. To be honest I don't like composer much either, and I use it sparingly. Luckily for me [Plesk](https://www.plesk.com), which I am using, supports an UI for composer, which takes away a lot of the pain of working with it. Still, I don't like to drag in all kind of packages from who knows whom. I guess I am not very trusting. Anyway, my point is that I'm not the person to advice you on the use of composer, all I know is that doing without it is virtually impossible. – KIKO Software Feb 20 '23 at 13:45
  • @KIKOSoftware yeah I actually saw that manual installation, but can you guide me through? all I can see in there is just to download the "dompdf_2-0-3.zip". I mean like which files should I put to my CodeIgniter 3 folders? and where to put it in order to run DomPDF perfectly? – whileiam Feb 20 '23 at 22:51
  • I don't use CodeIgniter 3, so I have no idea. Anyway, you can put the content of the ZIP file anywhere as long as the `require_once 'dompdf/autoload.inc.php';` can reach it from the code in which you want to use DomPDF. It's just like any other include. – KIKO Software Feb 20 '23 at 23:07

0 Answers0