× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Aaron,

No need to HTTP as you can run PHP in CLI mode. :-)

Regards,

Mike

mike.p@xxxxxxxx Cell: (408)679-1011 Office: (815)722-3454

Zend Server for IBM i Beta avilable at
http://www.zend.com/en/products/server/zend-server-5-new-ibmi



-----Original Message-----
From: web400-bounces@xxxxxxxxxxxx [mailto:web400-bounces@xxxxxxxxxxxx]
On Behalf Of Aaron Bartell
Sent: Friday, February 26, 2010 9:20 AM
To: Web Enabling the AS400 / iSeries
Subject: Re: [WEB400] Zend PDF and the RPG Experiment

Thanks Mike. I will check into this, but was really hoping for a
smaller
footprint solution for this particular situation which is why a small
PHP
runtime that I could invoke from RPG (without the need for HTTP) would
be
ideal.

BTW, I will be loading up CE real soon (once it is GA0 as I hope to use
that
to host mediawiki to do product documentation.

Aaron Bartell
http://mowyourlawn.com
http://mowyourlawn.com/blog/


On Fri, Feb 26, 2010 at 8:48 AM, Mike Pavlak <Mike.Pavlak@xxxxxxxx>
wrote:

Aaron,



I am starting a new thread.



I was hoping someone would open the door for PHP. I would recommend
Zend Server for IBM i Community Edition. (GA, VERY soon, beta
available
at link below) This is the no charge runtime for PHP and includes Zend
Framework. Why do I mention ZF? Simply because there is support for
Zend_PDF which supports a template approach to PDF generation. I am
working with some folks to put an nice example here. See this link
for
the documentation on Zend_PDF for more details:
http://framework.zend.com/manual/en/zend.pdf.html



Once you start with PHP, you may never go back to Java ;-)



Of course, you can use FPDF in this environment too.



I am not aware of another solution to deliver PHP to IBM i short of
Rob
Ward. But all I see of his previous site is a blog now. If you hear
of
one I would like to know.



Below is a really BASIC example of Zend_PDF in action without a
template. It's not gl;amorous but I think you get the idea. There
are
quite a few interesting components in this little hunk of code. In
addition to the Zend_PDF example is an example of how you can use the
library list in PHP, using PHP functions, DB2 error trapping, DB2
Fetch
of a record into an associative array (one of my favorites) and the
use
of the root file system to drop the PDF. Once it is there you can do
with it what you want like attach it to an email, archive, etc.



Why buy tools when you can get this for free?





Regards,



Mike Pavlak

Solutions Consultant

Zend Technologies, Inc.

(815)722-3454

(408)679-1011

mike.p@xxxxxxxx



Check out my blog at http://mikepavlak.blogspot.com/



Zend Server for IBM i Beta avilable at
http://www.zend.com/en/products/server/zend-server-5-new-ibmi





<?php







// Bring in the PDF classes from Zend Framework

require_once 'Zend/Pdf.php';



// Read through detail records...

//Function to get Order Details...



function getConnection() {



$conn = "*LOCAL"; $name = "PHPUSER"; $pwd = "phpuser";

$LibraryList = array("i5_lib"=>"ZENDSMP010"); // Yes, you can
use a library list in PHP...

$db2_link = db2_connect($conn, $name, $pwd, $LibraryList);

if (!$db2_link) {

echo 'Connection failed: '.db2_stmt_error().' :
'.db2_stmt_errormsg();

exit;

}

return $db2_link;

}



function getSales($orderNumber){

$sql = "SELECT * from SALESLINE where SALESLINE_ORDER =
$orderNumber";



global $db2_link; // Share connection to DB...



$Sales_Rec = db2_exec($db2_link, $sql); // Execute the
query

if (!$Sales_Rec) {

echo "SQL statement $sql Call Failed: " .db2_stmt_error().'
: '.db2_stmt_errormsg();

exit;

}



// Roll through the sales records for this order and
calculate values...

/* echo '<table><tr><td>Order Number</td><td>Line Number</td>

<td>Product Number</td><td>Quantity</td><td>Line
Sales</td>'; */

while ($row=db2_fetch_assoc($Sales_Rec)) {

$lineCount++;

$lineSales+=($row[SALESLINE_QUANTITY]*$row[SALESLINE_PRICE]

*
(1-$row[SALESLINE_DISCOUNT]));

$return[$lineCount]=
array($row[SALESLINE_ORDER],$row[SALESLINE_NUMBER],


$row[SALESLINE_PRODUCT], $row[SALESLINE_QUANTITY],

$lineSales);



}

return $return;

// echo "</table>";

}



$db2_link = getConnection();

$return = getSales(5); //hard code order number for convenience...



// Create a new PDF object

$pdf = new Zend_Pdf();



// Create a new PDF page

$pdf->pages[] = ($nextPage =
$pdf->newPage(Zend_Pdf_Page::SIZE_LETTER_LANDSCAPE));



// Create a new font

$font =
Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA);



// Apply the font

$nextPage->setFont($font, 20);



// Print the first line of data on the page

$dataLine = "Sales Detail report for order 5\n";

$printLine = 576;

$nextPage->drawText($dataLine, 72, $printLine);



// Print the remaining lines of data

foreach ($return as $index=> $value)

{

$printLine -= 21;

$amount = sprintf("$%.2f", $value[4]);

$text="Order: {$value[0]} Line: {$value[1]}
Product: {$value[2]}

Quantity: {$value[3]}
Amount:
$amount";

$nextPage->drawText($text, 72, $printLine);

}



// Save the PDF in directory /tmp/pdf

$pdf->save("/tmp/pdf/RPGSample.pdf");

unset($pdf);

echo "Order printed";

/* */



?>





--
This is the Web Enabling the AS400 / iSeries (WEB400) mailing list
To post a message email: WEB400@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/web400
or email: WEB400-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/web400.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.