Perl PDF API 2 error

Moderator: crythias

Locked
eXcite
Znuny newbie
Posts: 2
Joined: 05 Apr 2011, 10:59
Znuny Version: 3.0.6

Perl PDF API 2 error

Post by eXcite »

Hi
Im successfully upgraded my OTRS to 3.0.6, but when i try to create the custom PDF stats, i see an error:

Code: Select all

cannot find font '' ... at /usr/local/lib/perl5/site_perl/5.10.1/PDF/API2/Resource/CIDFont/TrueType/FontFile.pm line 424
OS: FreeBSD 8.2
Port p5-PDF-API2-2.019 already installed.
Thank in advance.
fxah
Znuny newbie
Posts: 1
Joined: 08 Apr 2011, 12:05
Znuny Version: 3.0.6

Re: Perl PDF API 2 error

Post by fxah »

Hi,

i just stumbled over the same issue on FreeBSD 8.1.

First I realized that I did not have any true type fonts installed on the machine. On my system OTRS was set up to use DejaVu as its default font (See Core::PDF module in the SysConfig module).

The font is available in the ports:

Code: Select all

cd /usr/ports/x11-fonts/dejavu
make install clean
The second problem was that PDF::API2 did not find the font. The port installs the font in /usr/local/lib/X11/fonts/dejavu. On my machine PDF::API2 searches

Code: Select all

../..//PDF/API2/fonts
/usr/local/otrs/bin/Custom/PDF/API2/fonts
/usr/local/otrs/bin/Kernel/cpan-lib/PDF/API2/fonts
/usr/local/otrs/bin/PDF/API2/fonts
/usr/local/otrs/bin/cgi-bin/../../Kernel/cpan-lib/PDF/API2/fonts
/usr/local/otrs/bin/cgi-bin/../../PDF/API2/fonts
/usr/local/lib/perl5/5.8.9/BSDPAN/PDF/API2/fonts
/usr/local/lib/perl5/site_perl/5.8.9/mach/PDF/API2/fonts
/usr/local/lib/perl5/site_perl/5.8.9/PDF/API2/fonts
/usr/local/lib/perl5/5.8.9/mach/PDF/API2/fonts
/usr/local/lib/perl5/5.8.9/PDF/API2/fonts
./PDF/API2/fonts|/usr/share/fonts
/usr/local/share/fonts|c:/windows/fonts|c:/winnt/fonts
Since I only have one font installed I decided to symlink /usr/local/lib/X11/fonts/dejavu to /usr/local/share/fonts.

Code: Select all

cd /usr/local/share
ln -s /usr/local/lib/X11/fonts/dejavu fonts
PDF::API2 is now happy and OTRS creates PDF without problems.
eXcite
Znuny newbie
Posts: 2
Joined: 05 Apr 2011, 10:59
Znuny Version: 3.0.6

Re: Perl PDF API 2 error

Post by eXcite »

Thank you fxah, now OTRS creates PDF without errors.
jimmypeter
Znuny newbie
Posts: 1
Joined: 30 Apr 2011, 09:41
Znuny Version: OTRS iPhone App
Real Name: jimmy
Company: interloop

Re: Perl PDF API 2 error

Post by jimmypeter »

Hi guys,,,,
When you run $pdf->stringify above, it returns the content of the file as a string, but then you don't do anything with it. If you were to print it, though, it would not give you the text representation you are after as it is simply the original PDF bytes in a string.

Likewise, setting $pagenum to 10 has no consequences for the rest of the program as the variable is not linked to either the $pdf or $page object in any way.

I think the easiest option is to not try to do this with PDF::API2, but to look at whether you can run something like pdftotext from xpdf or poppler first and then read in the output.
thanks,,,,,
JIMMY PETER
Locked