dougconran has asked for the wisdom of the Perl Monks concerning the following question:

I have an application that uses PDF::API2 (amogst other things to display jpg images) and PDF::TextBlock which has been running without problems on perl5.10.1. However I've just (foolishly, probably) upgraded my server and perl to v5.22.0. I've installed the relevant modules but I'm getting some really weird behaviour. Sometimes the pdf document will print with data and image but as often as not it just prints the initial blank pdf page (which I load from a base pdf doc). After exhaustive testing it would seem that $pdf->image_jpeg is one culprit the other being the TextBlock ->apply method. As far as I'm aware the problem areas work fine in another similar program and sometimes in this one. What's going on and does anyone have any idea how to fix it?

Replies are listed 'Best First'.
Re: Problems with PDF::API2 and TextBlock
by stevieb (Canon) on Sep 01, 2015 at 22:30 UTC

    Can you post your base doc along with the code you have? It's the only way we'll be able to try to replicate your issues.

    I took a look through the bugs and Changes files for both mentioned modules, but didn't see anything at a glance that looks related to your issue.

      Thanks for your reply. Things have moved on and, because of this and other problems I'm going to have to revert to the original server. I don't understand why but I suspect that this is being caused by some sort of clash using perl5.10.1 and perl5.22.0 modules (that or some inconsistency with underlying apps that the modules rely on). Once I've reverted to the old system I'll re-install the whole operating system on the new server and see if that fixes the problem.

        I am now completely and totally baffled by this problem!!

        I've done a complete re-install of the whole operating system + perl modules using the pre-installed perl5.10.1. All of this went almost without a hitch (I had a few problems installing both GD and Image::Magick) but I still end up with the same problem which seems to be totally random (it isn't, of course. I just don't know what's causing it!).

        The problem itself is that I have a PDF printing program (printing invoices) that calls in a base pdf doc for layout and then adds text and one or more images to the page. Each document may have more than one page (but generally only 1) and several line items. Each line item has a block of text which may or may not stretch to a second (or more) line. This block is printed using TextBlock.

        Generally only the base document is printed although, through debugging, I know that the data is being pulled from the database. On a few occasions when this happens a hard refresh will cause the full document to be printed, on other occasions (much more frequently) the page will print but will revert to just the base document if you do a hard refresh. As far as I can make out the program is more likely to display just the base document when the textblock stretches to more than one line or there are several line item descriptions close to the width of the textblock.

        It all works perfectly on the old server (using perl5.10.0) but not on the new one.

        I use Template Toolkit to manage text display and occasionally it will freeze at the point of displaying a list of records pulled from a Mysql database. Again, I have no idea why it happens but a hard refresh will always sort it out Maybe that could be a pointer?.

        I have a similar pdf printing program which, so far, works flawlessly. the only differences between them (other than data) is that the good one uses $pdf = PDF::API2->new and doesn't use Textblock whereas the bad one gets its base page by $pdf = PDF::API2->open('filename.pdf');

        I could paste the code but I just don't know what is relevant.

        Can anyone help a poor sinner!