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

  • Home
  • SEARCH
  • 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 6807711
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:51:56+00:00 2026-05-26T19:51:56+00:00

I have two code examples below. One works, but the second (using extend to

  • 0

I have two code examples below. One works, but the second (using extend to create a new class wrapper) doesn’t.

Note, I’ve greatly simplified the following examples.

Approach #1

page.php:

<?php

include("fpdf.php");
$pdf = new FPDF;
$pdf->AddPage();
$pdf->SetFont('Arial','',11);
$pdf->Output();

?>

This works as expected. It creates a blank page.

Approach #2

But then, using the FPDF by inheritance, I get an error (see below the code blocks).

myPDF.php:

<?php

require ("fpdf.php");

class myPDF extends FPDF {

    function createMyPage() {
        $this->AddPage();
        $this->SetFont('Arial','',11);
        $this->Output();
    }

}

?>

page.php:

<?php

include("myPDF.php");
$pdf = new myPDF;
$pdf->createMyPage();

?>

This second approach produces the following PHP warning and FPDF error:

Warning: in_array() expects parameter 2 to be array, null given in /var/www/fpdftest/fpdf.php on line 526 FPDF error: Undefined font: helvetica

Any ideas what I’m missing here?

  • 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-05-26T19:51:57+00:00Added an answer on May 26, 2026 at 7:51 pm

    When you create your wrapper class, be sure to call the parent constructor:

    <?php // Always use the full <?php open tag
    
    require ("fpdf.php");
    
    class myPDF extends FPDF {
    
        // Or, __construct() if you only care about PHP5
        function myPDF($orientation='P', $unit='mm', $size='A4') {
            // Call parent constructor
            $this->FPDF($orientation,$unit,$size);
            // Initialization
            $this->B = 0;
            $this->I = 0;
            $this->U = 0;
            $this->HREF = '';
        }
    
        function createMyPage() {
            $this->AddPage();
            $this->SetFont('Arial','',11);
            $this->Output();
        }
    
    }
    

    http://fpdf.org/en/tutorial/tuto6.htm

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two web pages which work basically the same, code-wise, but one of
I have two controllers which share most of their code (but must be, nonetheless,
I have these two pieces of code, wich one is more readable? foreach decimal
here is what my code looks like i have two forms: class Form_1 extends
I have two code bases of an application. I need to copy all the
I have the following two code blocks. Code block 1 var checkboxes = $(div.c1
I have two pieces of C++ code running on 2 different cores. Both of
I have two identical byte arrays in the following segment of code: /// <summary>
I have two string variables which are both file paths. The code that worked
Hi guys I wrote this code and i have two errors. Invalid rank specifier:

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.