I want to display image blob from db to fpdf

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • panha sim
    New Member
    • Jul 2020
    • 1

    I want to display image blob from db to fpdf

    Here is my code but it error
    =============== =============== =============== ========
    Code:
    $this->Cell(
        15,
        15,
        this->Image(
            $row['image'],
            $this->GetX(),
            $this->GetY(),
            15,
            15
        ),
        1, 0
    );
    Last edited by gits; Jul 21 '20, 05:23 PM. Reason: added code tags and make it somehow readable
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5388

    #2
    what error do you get exactly?

    Comment

    • bakertaylor28
      New Member
      • Feb 2021
      • 45

      #3
      The problem is that you can't pull from the SQL directly in FPDF, rather you need to store the blob in a global var and then use that, because FPDF can't interact with the SQL statement, because it is a class. A class can't interact with variables constructed outside the class UNLESS it is a global var. Thus you need something like:

      Code:
      global $image;
      $image = $row['image]';
      ...
       this->Image(
              $image,
      $this->GetX(),
              $this->GetY(),
              15,
              15
          ),
      ...

      Comment

      Working...