"L'anello più debole di un sistema di sicurezza è il fattore umano" Kevin D. Mitnick

(English) Convert a spool file to PDF using PHP on i5/OS

Posted: gennaio 30th, 2010 | Author: | Filed under: PHP | Tags: , , , | 8 Comments »

Ci spiace, ma questo articolo è disponibile soltanto in English.


8 Comments on “(English) Convert a spool file to PDF using PHP on i5/OS”

  1. 1 Alberto Ernestini said on febbraio 12th, 2010:

    Your article sound very interesting. As a Iseries specialist from too many years i’ve tried to set it up on a test system, but i may need better PHP experience :-)
    By example the i5spool asks also for a ‘JOBNR’ parameter and i wasn’t able to set the correct font. i still get a error.

    There is anything missing?
    Thanks a lot.
    Ciao.
    Alberto.

  2. 2 Enrico Zimuel said on febbraio 13th, 2010:

    Hi Alberto,
    What’s the error message that you got? Which version of ZF are you using?
    In the i5Spool class you can use the function getList($user[,$num]) to get all the data of the user’s spool files (the $num is an optional parameter to get only the first $num spool file).

  3. 3 Alberto Ernestini said on febbraio 15th, 2010:

    Hi , thanks for your prompt answer!
    This is the error :
    Catchable fatal error: Argument 1 passed to Zend_Pdf_Page::setFont() must be an instance of Zend_Pdf_Resource_Font, string given, called in /usr/local/Zend/5250/demos/emulation/i5Spool.php on line 111 and defined in /usr/local/Zend/ZendFramework/library/Zend/Pdf/Page.php on line 586

    and this is what i am having on my Iseries 515 :
    1ZCORE5 *BASE 5001 Zend Core for IBM i5/OS (2.6.1)
    1ZCORE5 1 5002 Zend Platform for IBM i5/OS (3.6.1 )

    The Zend FW version is 1.6.0.

    Thanks!
    Ciao.
    Alberto.

  4. 4 Enrico Zimuel said on febbraio 16th, 2010:

    Hi Alberto, did you tried to install the last ZF version? I guess this problem comes out using an old version of ZF. I tried the example in the post using ZF 1.9.6 on i5/OS and i didn’t found your error.

  5. 5 Alberto Ernestini said on febbraio 16th, 2010:

    Almost solved!!
    There was some problems on the Iseries side.
    A Codepage font problem reported as ‘ Wrong Charset conversion from utf-8 to CP1252//IGNORE is not allowed’.

    For this i had to modify the Font/Simple.php in this way :

    /Zend/Pdf/Resource/Font/Simple.php

    line 259, replace :

    return iconv($charEncoding, ‘CP1252//IGNORE’, $string);

    with

    return $string;

    and line 273, replace :

    return iconv(‘CP1252′, $charEncoding, $string);

    with

    return $string;

    (taken from a Zend Forum post of Mon, 04 August 2008)

    and also the other error was because of line 111 on i5spool.php under toPdf function

    $page->setFont($conf_pdf['font'],$conf_pdf['font-size']);

    changing it with this :
    $page->setFont(Zend_Pdf_Font::fontWithName($conf_pdf['font']),(int)$conf_pdf['font-size']);
    solved the font problem.

    there is also a extra addition on the i5spool.php, at the new page i had to add this line after line 123
    $page->setFont(Zend_Pdf_Font::fontWithName($conf_pdf['font']),(int)$conf_pdf['font-size']);
    this for set the font also on the new page.
    Now the code works well , except for the breakpage but i think i can fix it :-)
    Thanks a lot!
    Ciao
    Alberto

  6. 6 Enrico Zimuel said on febbraio 16th, 2010:

    Hi Alberto, i found that this was a bug of your ZF version. In the new version of ZF this issue has been solved with the management of AIX (i5/OS) environments.
    In /Zend/Pdf/Resource/Font/Simple.php in the new ZF version there is this patch:

    public function encodeString($string, $charEncoding)
    {
    if (PHP_OS == ‘AIX’) {
    return $string; // returning here b/c AIX doesnt know what CP1252 is
    }
    return iconv($charEncoding, ‘CP1252//IGNORE’, $string);
    }

    I suggest you to upgrade your version of ZF with the last one.
    Regarding the issue of the new PDF page in the i5Spool class I just fixed the problem. I updated the class in the post, thanks!

  7. 7 David Porter said on settembre 1st, 2010:

    Zimuel,

    Thanks for the Spool Class and information on using the i5 Toolkit for strong i5/OS interactions.

    I have a question: why does the i5_spool_get_data function only return a string, and being a string, why does it not return any of the formatting data associated with a print file such as boxes, simple lines or image overlays?

    I would love to use the toolkit to convert spool data to PDF but I need all of the spool data, not just a long string of unformatted text.

    Does that make sense?

  8. 8 Enrico Zimuel said on settembre 3rd, 2010:

    Hi David,
    unfortunately the i5_spool can manage only strings, no images. If you need to convert complex spool file to PDF I suggest to use the CVT2PDF (http://www.code400.com/cvt2pdf.php) and call it with the i5 Toolkit from PHP.


Leave a Reply

  • Spam Protection by WP-SpamFree