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"

  • 4 Replies
  • 171 Views
*

Offline Phil

  • Global Moderator
  • Hero Member
  • *****
  • 681
    • View Profile
Wed Feb 19 22:03:03 2020 tturner@torrid-tech.com - 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:    <bug-PDF-API2@rt.cpan.org>
From:    "Tim Turner" <tturner@torrid-tech.com>

Hi,
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:
Quote
Can't locate object method "image_jpeg" via package "PDF::API2" at /var/www/vhosts /httpdocs/cgi-bin/somepathSNIPPED/custom_setup.pl line 220

Google that error and find nothing of value.
 
If I change the method to just image without the jpeg I get:
Quote
2020] dist.cgi: image '/var/www/vhosts/webcalcs.com/httpdocs/docs/SNIP/images/logo_PLifeVert_4_C.jpg' has unknown format with signature '000000000000' at /usr/local/share/perl5/PDF/API2.pm line 5914., referer: <https://www.webcalcs.com/cgi-bin/calcs/prod/distributions.cgi?client=pacifi
clife&case=gen_72T> url removed

Any help or advice appreciated.  Other info below.

Regards,
-Tim
 
-----------------
Be sure to include at least the following information:
*       Distribution name and version (For example,
"DBIx-SearchBuilder-0.46")
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/FTP.pm 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 pluto.ourcontrolpanel.com 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 PMPERRY@cpan.org - 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 PMPERRY@cpan.org - 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
  • *****
  • 681
    • View Profile
Thu Feb 20 13:03:08 2020 tturner@torrid-tech.com - Correspondence added

Phil,
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:
Quote
-bash-4.1$ perl -MPDF::API2 -le 'print $PDF::API2::VERSION'
0.2.3.8

-Tim

Thu Feb 20 15:52:57 2020 tturner@torrid-tech.com - Correspondence added

The version number does not make sense at 0.2.3.8
But I found this in the list of installed modules:
PDF-API2-0.2.3.8_fix1/lib/Text/PDF/ImageJPEG.pm

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

Also installed is the regular PDF-API2 tree
/usr/share/perl5/vendor_perl/PDF/API2/Resource/XObject/Image/JPEG.pm
etc.

-Tim

Thu Feb 20 16:02:54 2020 tturner@torrid-tech.com - 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/PDF.pm 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 Text.pm 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 PMPERRY@cpan.org - Correspondence added

I have no idea what 0.2.3.8 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 PMPERRY@cpan.org - 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. cpan.org contains all this information.

*

Offline Phil

  • Global Moderator
  • Hero Member
  • *****
  • 681
    • View Profile
Sun Feb 23 10:19:24 2020 PMPERRY [...] cpan.org - Correspondence added

Looking a bit into the history of PDF::API2, it appears that it started with a wrapper around Text::PDF::API. That was at least 15, perhaps closer to 20, years ago! If you're trying to run a version of PDF::API2 that actually depends on Text::PDF, it means it is very very very old. Old as the hills and twice as dusty.

Either kick your host in the butt to get the server updated to current levels (including current Perl), or do your work on a PC where you can control what's installed. There is no rational reason to be running on such old Perl or PDF::API2 levels. As I said before, unless you need online automated creation of PDFs as part of a website, take it off the server and run them on your PC.

Mon Feb 24 12:39:17 2020 tturner [...] torrid-tech.com - Correspondence added

Hi Phil,
We uninstalled and reinstalled and got the image_jpeg working.
YES this is a web server app that is in production and used by clients so fixing it is a must do and PC is not an option.

The only issue left now is text->paragraph in some cases has no spaces in the text when it is added to the document.  I set the "lead" on the font.  Still stumped by that one.  It wasn't an issue before.  All of this has worked for years and moving to an updated server is causing all of the issues.

Anyway have you seen text written with no spaces between words before?

Thx
-Tim

Mon Feb 24 19:06:26 2020 tturner [...] torrid-tech.com - Correspondence added

Phil,
As for your other questions... the call to paragraph just provides a long string of text that already includes the spaces.  When placed on the document though the spaces are gone.  Never seen that in 10+ years using the module.

If I switch to PDF::Builder... do you have a guide of some sort of what code changes if any need to be made if not using PDF::API2???

-Tim

Tue Feb 25 12:16:26 2020 PMPERRY [...] cpan.org - Correspondence added

Could you provide a small test case illustrating this problem? I'm not seeing it when I run with either PDF::API2 or PDF::Builder. And what version of Perl and PDF::API2 are you running now?

PDF::Builder is intended to be largely compatible with PDF::API2. Obviously you need to change all "PDF::API2" to "PDF::Builder". If you're using some more esoteric features, especially deprecated names that have already been removed from Builder, you should look at INFO/DEPRECATED and INFO/KNOWN_INCOMP for known incompatibilities.

*

Offline Phil

  • Global Moderator
  • Hero Member
  • *****
  • 681
    • View Profile
Tue Feb 25 21:58:26 2020 tturner [...] torrid-tech.com - Correspondence added

Phil,
As I emailed before I have 2.3.7 version of API2 but older 5.10.1 version of Perl. 
Hosting company says that version is what is shipped with the server.

Nevertheless, I found the problem and it was adding: align => 'justified'
Removing that fixed the problem, but on older version of API2 that worked fine.

I may at some point switch to Builder but for now I just have to get these scripts working in production again.

Many thanks for your help.

Regards,
-Tim

Tue Feb 25 23:23:37 2020 PMPERRY [...] cpan.org - Correspondence added

PDF::API2 2.037 will supposedly still run on Perl 5.010. PDF::Builder requires 5.018 to install; I don't know if it will run on earlier Perls.

I took a quick look at the "justified" code, and see something that MAY be an issue: in Content.pm's text_fill_justified method, there is a call to "scalar split /\s/, $line". I vaguely recall seeing error messages about such a construct in more recent Perl versions -- could it be that your host has configured Perl to suppress warning messages (especially deprecated functions)? Anyway, just to see if you can use "justified", try changing that line to "scalar(split(/\s/, $line))". You have only normal ASCII spaces between words? That's all I can think of at this point.

If at some point you decide to install PDF::Builder, and have issues, please open a support ticket there instead of here, to keep from cluttering up the PDF::API2 support system. Good luck!

Wed Feb 26 15:10:22 2020 tturner [...] torrid-tech.com - Correspondence added

Hey Phil,
This code change fixed the problem with justified text in paragraph! Indeed this was the trouble all along.

So is API2 not really supported anymore and that is why you started Builder? If API2 is supported, why would that item not be fixed in the latest version?

Thank you so much for your help!
Regards,
-Tim

Wed Feb 26 17:59:53 2020 PMPERRY [...] cpan.org - Correspondence added

On Wed Feb 26 15:10:22 2020, tturner@torrid-tech.com wrote:
Quote
Hey Phil,
This code change fixed the problem with justified text in paragraph! Indeed this was the trouble all along.

That's great to hear! So your production system is now up and running?

Quote
So is API2 not really supported anymore and that is why you started Builder? If API2 is supported, why would that item not be fixed in the latest version?

I wouldn't say that API2 isn't supported any more -- 2.037 was just released a few weeks ago. For whatever reason, Steve has chosen not to fix it yet. I started Builder because I wasn't happy with the rate of fixing things on API2, and wanted to put other features in that Steve didn't want in it.
 
Quote
Thank you so much for your help!
Regards,
-Tim

Wed Feb 26 18:03:26 2020 tturner [...] torrid-tech.com - Correspondence added

Yes production system is back in running order!

*

Offline Phil

  • Global Moderator
  • Hero Member
  • *****
  • 681
    • View Profile
Bug in PDF::API2, but not in PDF::Builder. Closing.