Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8406627
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:09:39+00:00 2026-06-09T23:09:39+00:00

require(‘inc/fpdf.php’); require(‘inc/mem_image.php’); class PDF extends FPDF { // Colored table function FancyTable() { $this->SetFont(‘Helvetica’,’B’);

  • 0
require('inc/fpdf.php');
require('inc/mem_image.php');



class PDF extends FPDF
{
    // Colored table
    function FancyTable()
    {
        $this->SetFont('Helvetica','B');
        $this->Cell(27, 4, 'Other Title', 1, 0);
    }  
}


$pdf = new PDF_MemImage();
//$pdf = new PDF();
$pdf->SetFont('Helvetica','',7);
$pdf->AddPage();

$img = file_get_contents('logo.jpg');

$pdf->MemImage($img, 50, 30);
$pdf->Cell(20,10,'Title',1,1,'C');

//$pdf->FancyTable();
$pdf->Output();

I am trying to incorporate the mem_image script into my existing FPDF pages. I am using a method called fancyTable to set up my table data/layout. Unfortunately trying to call fancyTable breaks the page (blank). If I comment it out, its fine. If I switch out the $pdf declaration to new PDF() instead of new PDF_memimage() fancyTable works, but obviously my image doesn’t load. I think its probably just a conflict with the class, but I am not versed in OO syntax.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T23:09:41+00:00Added an answer on June 9, 2026 at 11:09 pm

    The solution to this is actually quite straight forward: you have extended the wrong class.

    All you need to do to fix it is change this:

    class PDF extends FPDF
    

    …to this:

    class PDF extends PDF_MemImage
    

    …and then change this:

    $pdf = new PDF_MemImage();
    

    …to this:

    $pdf = new PDF();
    

    By extending FPDF, you have created a new branch in the inheritance tree based on the trunk (FPDF), whereas what you want to do is base it on the existing branch PDF_MemImage.

    For the record, naming your class PDF is probably not a great idea – firstly it’s not very descriptive (it doesn’t indicate that it inherits from FPDF or MemImage) and secondly it is very short and would run the risk of collision with another class if used as part of a larger application. I personally would call it FPDF_MemImage_FancyTable, YMMV.

    Also, in this day and age, there really is no need to write classes that are PHP4 compatible. (In saying this, I actually do need to do this occasionally, but I doubt you do)

    EDIT

    In case it’s not clear from the above description, the final code would look like this:

    require('inc/fpdf.php');
    require('inc/mem_image.php');
    
    class FPDF_MemImage_FancyTable extends PDF_MemImage
    {
        // Colored table
        function FancyTable()
        {
            $this->SetFont('Helvetica','B');
            $this->Cell(27, 4, 'Other Title', 1, 0);
        }  
    }
    
    $pdf = new FPDF_MemImage_FancyTable();
    
    $pdf->SetFont('Helvetica','',7);
    $pdf->AddPage();
    
    $img = file_get_contents('logo.jpg');
    $pdf->MemImage($img, 50, 30);
    
    $pdf->Cell(20,10,'Title',1,1,'C');
    
    $pdf->FancyTable();
    
    $pdf->Output();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: PHP: Require() and Class Hierarchies Is this bad practice? Is there any
require_once('/recaptcha/recaptchalib.php'); was in the correct place but the error says: Warning: require_once() [function.require-once]: open_basedir
require_once('phpmailer/class.phpmailer.php'); function smtpmailer($to,$from,$subject,$body) { define('GUSER', 'xxx'); // Gmail username define('GPWD', 'xxx'); // Gmail password
require_once('classes/class.validation.php'); $array = $_POST['array']; $pass_profanity = false; $validation = new Validation; function check_for_profanity($input){ if(is_array($input)){
I require a button/link within a table row of a QTableView . This is
I require a tree / directed acyclic graph implementation something like this: public class
require( dirname(dirname(dirname(dirname(dirname(dirname(dirname( __FILE__ ))))))).'/wp-load.php' ); this is the code im using at present. The
require dirname(__FILE__).'/yahooPHP/lib/Yahoo.inc'; This line is in one file in one directory and I am
require(raster) ## Function to aggregate fun.patch <- function(x) { if (max(table(x)) >= 0.9 *
require 'coderay' puts CodeRay.scan('puts Hello, world!', :ruby).page This code will print full HTML page

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.