CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 Grabbing Report Variables

Print topic Send  topic

Author Message
TonyReid


Posts: 159
Posted: 07/25/2007, 2:27 AM

I need to grab the data from a report (built using report builder) so that I can send it to a nicely formated pdf.

The PDF bit doesn't worry me - I think I have a handle on that, but how can I grab the data after the page has been displayed?

Any thoughts/help appreciated.




_________________
-----------
PHP/indy Game Developer - http://www.AbsoluteBreeze.co.uk
View profile  Send private message
datadoit.com
Posted: 07/25/2007, 5:58 AM

TonyReid wrote:
> I need to grab the data from a report (built using report builder) so that I can
> send it to a nicely formated pdf.
>
> The PDF bit doesn't worry me - I think I have a handle on that, but how can I
> grab the data after the page has been displayed?
>
> Any thoughts/help appreciated.
>
>
>
>
> _________________
> Using: CodeCharge Studio 3.0 - IIS, PHP and MSSQL
> ---------------------------------------

What PDF generator are you using? I would suggest fpdf/fpdi - easy breezy.

Typically your PDF generator will have a running variable such as
'$pdf', which will be rendered when ready. As your components in your
report are generated or displayed, you'll also populate your $pdf
variable at that time. This will happen in many places: Page
BeforeShow, Component BeforeShow, Grid BeforeShowRow, etc.

I like to have a page that renders to HTML as normal, and then a
duplicate page that will stream the contents to a PDF document. Both
pages 'look' the same in the CodeCharge designer. It may be possible to
do this with a single page, and maybe create a button that launches that
page's contents to a PDF. Haven't played with that concept though.
TonyReid


Posts: 159
Posted: 07/25/2007, 6:47 AM

Im using ezpdf which looks similar to the classes you mentioned.
http://www.ros.co.nz/pdf/

Although I use it outside of CCS and just call it as a standalone generator from my codecharge page/app.

Here is an example code
  
  
if ($row["type"]==1) {  
		$pdf->addText(161,451,12,$row["charity_name"]);  
		$pdf->addText(111,340,12,$row["donation"]);  
        	  
                //Squirt it to pdf!!!!  
                $pdf->stream();  
                }  
  

I guess your suggestion is to build up the pdf variable although I am afraid to say im not sure of the best way to do this :(



_________________
-----------
PHP/indy Game Developer - http://www.AbsoluteBreeze.co.uk
View profile  Send private message
datadoit.com
Posted: 07/25/2007, 9:01 AM

Perfect. Ezpdf is very flexible.

From your example, you're already 'building up' the $pdf variable. At
the end you're spitting it's contents to the browser. Be careful here
though. I've run into the memory limitation on that, but it was after
about 300 pages of content!

So your 'building up' takes place in areas such as component's
BeforeShow, or grid's BeforeShowRow, etc. At the bottom of the page, I
like to just put in a label control, and in the label control's
BeforeShow event, place the $pdf->stream() function.

Just make sure you have 'global $pdf' all over the place.

I used to use Ezpdf exclusively, but our usage was mostly forms-based
PDF's. So I switched to fpdf/fpdi, since it allowed me to let someone
else create and manage the form designs, while I just overlayed the data
on top of them.
TonyReid


Posts: 159
Posted: 07/30/2007, 12:48 AM

Thanks for your help on this.

I've been trying this every which way I can - although I still end up looking at a blank white screen.

Tony

_________________
-----------
PHP/indy Game Developer - http://www.AbsoluteBreeze.co.uk
View profile  Send private message
TonyReid


Posts: 159
Posted: 07/30/2007, 5:34 AM

** Edit: sorry - stupid comment, I've removed it.
_________________
-----------
PHP/indy Game Developer - http://www.AbsoluteBreeze.co.uk
View profile  Send private message
datadoit.com
Posted: 07/30/2007, 6:45 AM

TonyReid wrote:
> The blank screen appears to be caused by ..
>
>
  
> global $pdf;  
> $pdf = new Cpdf();
>
> Even though the class file is included.
>
> _________________
> Using: CodeCharge Studio 3.0 - IIS, PHP and MSSQL
> ---------------------------------------

Don't recognize the Cpdf(). What is that?

It's a class file, so open the file and look for the Cpdf() class or
function to make sure it's there. Also check for other dependencies and
files within that class.
TonyReid


Posts: 159
Posted: 07/30/2007, 6:58 AM

I got that bit working :)

Just stuck on getting the variables out to pdf - I can do test data - just not stuff from the form.

I have a file called report.php and report_events.php

The report is called Bwip_Security_sheet.

At the bottom of the page(outside the report) I have a label called ReportLabel1...


In the before show event of this label (report_events.php) I have some custom code :

  
global $pdf;  
global $testing;  
  
$testing = $Bwip_Security_Sheet->ReportLabel1->GetValue();  
  
$pdf = new Cpdf();  
$pdf->addText(161,451,12,$testing);  
$pdf->stream(); 

That code above should cause a pdf to be generated - however I just end up looking at a blank screen.



_________________
-----------
PHP/indy Game Developer - http://www.AbsoluteBreeze.co.uk
View profile  Send private message
datadoit.com
Posted: 07/30/2007, 7:05 AM

At the very top of your *_events.php code, put:

global $pdf;

Let's see if that solves it.
TonyReid


Posts: 159
Posted: 07/30/2007, 7:21 AM

It doesn't - but if I change the variable like this...

Quote :
global $pdf;
global $ReportLabel1;
global $testing;

//$testing = $Bwip_Security_Sheet->ReportLabel1->GetValue();
$testing='test';
$pdf = new Cpdf();
$pdf->addText(161,451,12,$testing);
$pdf->stream();

It outputs the PDF
_________________
-----------
PHP/indy Game Developer - http://www.AbsoluteBreeze.co.uk
View profile  Send private message
datadoit.com
Posted: 07/30/2007, 7:45 AM

TonyReid wrote:
> It doesn't - but if I change the variable like this...
>
>
Quote :
> global $pdf;
> global $ReportLabel1;
> global $testing;
>
> //$testing = $Bwip_Security_Sheet->ReportLabel1->GetValue();
> $testing='test';
> $pdf = new Cpdf();
> $pdf->addText(161,451,12,$testing);
> $pdf->stream();
>
> It outputs the PDF
> _________________
> Using: CodeCharge Studio 3.0 - IIS, PHP and MSSQL
> ---------------------------------------

In the ReportLabel1 BeforeShow event, you need to 'build' your $pdf
variable there. Something like:

global $pdf;
$pdf->addText(161,451,12,$Component->GetValue());

Basically, here are the rules:

Top of your events code, put:

<?php
global $pdf;

Then, in the Page BeforeShow:

global $pdf;
$pdf = new Cpdf();

Then build your $pdf as you go down the page (labels, controls, etc.),
always bringing along your $pdf variable (global $pdf).

Finally, put a label control at the bottom of your page, where in the
BeforeShow, you'll put:

global $pdf;
$pdf->stream();
TonyReid


Posts: 159
Posted: 07/30/2007, 7:49 AM

I've got that bit working - just need to play around with loops and build the $pdf :)

Thanks for your help with this.

Tony


_________________
-----------
PHP/indy Game Developer - http://www.AbsoluteBreeze.co.uk
View profile  Send private message
TonyReid


Posts: 159
Posted: 08/01/2007, 12:24 AM

Just a quick post to say its all pretty much done now :)

So , Thank you for your help.

Tony

_________________
-----------
PHP/indy Game Developer - http://www.AbsoluteBreeze.co.uk
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.