Search code examples
oracle-databaseblobfpdf

Load blob image in fpdf


I am trying to load an image from oracle database Blob file. To load image i am using the following code

$COM_CODE = 'O003';  
$sql = 'select DIGI_SIGN from LC_BLOCK_LIST_TECH_PERS where COM_CODE :COM_CODE';
$s = oci_parse ($c, $sql);
oci_bind_by_name($s, ':COM_CODE', $COM_CODE);
oci_execute($s, OCI_NO_AUTO_COMMIT);
$arr = oci_fetch_assoc($s);
$result = $arr['DIGI_SIGN']->load();
$pdf->Cell(40,5,$result,0,1,'L',0);

Nedd to show the image in a cell. In last cell i am not able to show the image instead binary value shows up. what am i doing wrong here?


Solution

  • from here, it looks like you need to first create a file, then use standard procedure to write the image to the pdf:

    $result = $arr['DIGI_SIGN']->load();
    // Here: new question: [php] how to write  image file from Oracle BLOB?
    // $result goes to a file on server:  "/var/appli/img/products/image1.jpg"
    
    $image1 = "/var/appli/img/products/image1.jpg";
    $pdf->Cell( 40, 5, $pdf->Image($image1, $pdf->GetX(), $pdf->GetY(), 30), 0, 1, 'L', 0);
    

    Hope it helps.