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

Dear Monks
The module PDF::API2 dies instead of indicating the failure. I use it combine the PDF I have generated via htmldoc.
$pds = PDF::API2->open($sourcepdf);
PDF::API2::IOString=GLOB(0x8951394) not a PDF file version 1.x at /usr +/local/lib/perl5/site_perl/5.8.3/PDF/API2/PDF/FileAPI.pm line 76.
I need some solution, so either I can convert into a proper PDF file or ignore it.
Thanks,
artist

Update 1: Thanks to davido, The answer works. Now, What are my options if I don't want to ignore.

2004-05-12 Edit by jdporter: Changed title from 'Combing PDF'

Replies are listed 'Best First'.
Re: Unexpected file version error from PDF::API2
by davido (Cardinal) on May 11, 2004 at 16:09 UTC
    If ignoring failure is acceptible, you could just wrap the call to PDF::API2->open() in an eval.

    eval { $pds = PDF::API2->open( $sourcepdf ) }; print "Not a recognizable PDF format\n$@" if $@;

    ...Untested. I'm assuming that PDF::API2 doesn't do something that would prevent you from trapping errors.


    Dave

Re: Unexpected file version error from PDF::API2
by bart (Canon) on May 11, 2004 at 18:05 UTC
    The module PDF::API2 dies instead of indicating the failure.
    It dies with an indication of failure. The reason is this:
    not a PDF file version 1.x
    It would appear as if the file isn't corrupt, but just too new a version of PDF file format. This seems extremely odd to me, as I thought even Acrobat 5 only produces PDF 1.4 files. This just can't be right.

    eval BLOCK is indeed the best general mechanism to trap this.

    As for the cause... what is this htmldoc you were talking about? I suspect a problem with binary vs. text mode, but that's just a guess.

      I looked at source PDF file and it was size 0. Sometime that htmldoc fails to produce the PDF file and resulting the error. Anyway, the error indicated the wrong reason.