Post without Account — your post will be reviewed, and if appropriate, posted under Anonymous. You can also use this link to report any problems registering or logging in.

[RT 131887] Can't locate object method "image_jpeg" via package "PDF::API2"

  • 1 Replies

Offline Phil

  • Global Moderator
  • Hero Member
  • *****
  • 626
    • View Profile
Wed Feb 19 22:03:03 2020 - Ticket created [Reply] [Forward]
Subject:    Can't locate object method "image_jpeg" via package "PDF::API2"
Date:    Wed, 19 Feb 2020 21:56:16 -0500
To:    <>
From:    "Tim Turner" <>

I have used PDF::API2 for at least 10 years or more. My web provider is forcing me to use a new server. Moving all my code over. and it's just not working. PDF::API2 is indeed installed and I can generate a PDF but problem is with adding a JPEG.
First issue is that it doesn't recognize image_jpeg at all.  I did not change the code and it barfs on image_jpeg. I get this message:
Can't locate object method "image_jpeg" via package "PDF::API2" at /var/www/vhosts /httpdocs/cgi-bin/somepathSNIPPED/ line 220

Google that error and find nothing of value.
If I change the method to just image without the jpeg I get:
2020] dist.cgi: image '/var/www/vhosts/' has unknown format with signature '000000000000' at /usr/local/share/perl5/PDF/ line 5914., referer: <
clife&case=gen_72T> url removed

Any help or advice appreciated.  Other info below.

Be sure to include at least the following information:
*       Distribution name and version (For example,
cpan -D PDF::API2
CPAN: Storable loaded ok (v2.20)
CPAN: LWP::UserAgent loaded ok (v5.833)
CPAN: Time::HiRes loaded ok (v1.9721)
mkdir /root: Permission denied at /usr/share/perl5/CPAN/ line 501
*       Perl version (Find this by running the command perl -v)   
Perl v5.10.1
*       Operating System vendor and version (Find this by running the
command uname -a)
Linux 2.6.32-896.16.1.lve1.4.51.el6.x86_64 #1 SMP
Wed Jan 17 13:19:23 EST 2018 x86_64 x86_64 x86_64 GNU/Linux

Thu Feb 20 09:36:23 2020 - Correspondence added

Is there any way for you to check what the PDF::API2 version is? Maybe run $pdf->version(); and print the result? I take it that it is installed on a webserver and not your local PC. If your host is making you use Perl 5.10, which is incredibly ancient and out of support (5.18 is minimum supported, and 5.30 is current), I wouldn't be surprised if their PDF::API2 is either way back-level (2.037 is current) or was corrupted during installation. Have you brought this to their attention? If you have a PC (Windows, Linux, or Mac), consider installing and running PDF::API2 (or PDF::Builder) on it and running there. Unless you need unattended online (web) PDF creation, this would be better.

Thu Feb 20 09:57:52 2020 - Correspondence added

P.S. The "image" method is not for directly handling JPEG images. It needs as input something that has already gone through "image_jpeg". As I said before, either your server's copy of PDF::API2 is so old that it doesn't include JPEG support (I don't know if it ever didn't) or it was corrupted or misconfigured in some way.


Offline Phil

  • Global Moderator
  • Hero Member
  • *****
  • 626
    • View Profile
Thu Feb 20 13:03:08 2020 - Correspondence added

Thanks for responding.  I will ask about the perl version but I don't think that is the issue. My old server that everything worked on used ancient Perl 5.8.8.  It all worked so we left it alone.

Here is the module version:
-bash-4.1$ perl -MPDF::API2 -le 'print $PDF::API2::VERSION'


Thu Feb 20 15:52:57 2020 - Correspondence added

The version number does not make sense at
But I found this in the list of installed modules:

Not sure what this fix is.... maybe that whole tree needs to be uninstalled?

Also installed is the regular PDF-API2 tree


Thu Feb 20 16:02:54 2020 - Correspondence added

Also what are the pre-requisites for PDF::API2 if any?

Does Text/PDF need to be installed?
I see it in my list of perl modules but a version check says it can't be located.

I tried searching for Text::PDF
Code: [Select]
-bash$ perl -MText::PDF -le 'print $Text::PDF::VERSION'
Can't locate Text/ in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .).
BEGIN failed--compilation aborted.

And then just Text
Code: [Select]
-bash$ perl -MText -le 'print $Text::VERSION'
Can't locate in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .).
BEGIN failed--compilation aborted.

Thu Feb 20 18:07:25 2020 - Correspondence added

I have no idea what refers to. It's certainly not a PDF::API2 version from the last 10 or 15 years. It might be some packager's internal number. If they've modified PDF::API2 then they are on the hook for maintaining it.

Perl 5.8.8 is so behind the times that it's dangerous to use. Certainly the current products will have problems running on something that old. If you choose to stay so far behind, I can't help you any further. Good luck!

Thu Feb 20 18:16:53 2020 - Correspondence added

Current and recent PDF::API2 releases had nothing to do with Text::PDF. Its runtime requirements are Font::TTF and Compress::Zlib. The installation and build package may require Test::Exception, Test::Memory::Cycle, and ExtUtils::MakeMaker. contains all this information.