Tim,

That is very interesting, thanks a lot. I will have to digest it to fully get the technique. I might then bother you again with my questions ;-)

Cheers,


Youri


Tim Hare wrote:
Youri,

When you open a printer in RB, you get a graphics object back.  That
graphics object is sized to the paper selected, minus the margins.  In other
words, it is sized to the printable area.  To print anything, all you have
to do is draw using the graphics object: DrawString, DrawRect, FillRect,
etc.

When I want to preview the report, I display a window with a canvas, and
resize the canvas and window to match the dimensions of the printer's
graphics object (scaled to the correct vertical/horizontal resolution).  I
then get the canvas' graphics object and pass that to the report.

Of course, a canvas is merely a display device; a place to render the data
that represents the report.  If you just want to print to the printer, it's
a one pass thing; you draw to the page and it's done.  If you want to
display on a canvas, you have to buffer the information that makes up a
page, and render it in the paint event of the canvas.  That way, you can
move the window, obscure and restore the window, and not lose the image of
the report.  That also allows me to let the user resize the window, and then
scale the data to the new size.

You wind up with 2 views of the data: the Report view, which is in terms of
"universal coordinates" (arbitrarily chosen to make the report easy to think
about - I use 100ths of an inch - think columns in the old world of 10cpi
printers and divide into tenths), and the Display view, which is scaled to
the printer resolution, or to screen resolution (using RB's fictitious 72dpi
at normal window size, and scaling from there on resize).

To make things easy, the Report typically thinks about vertical space in
terms of lines at 6 lines/inch.  It can also use universal coordinates,
though, for things like boxes and shading if need be.  Both are converted as
appropriate when rendered.

You build some mechanism of your own design to make it convenient and easy
for the report to spit out little chunks of data: bits of strings and shapes
at some X,Y coordinate.  You collect these bits of data into pages and
render each page at the appropriate time.  If you're just printing to the
printer, you can render as you go.  If you want to preview as well, then
you'll have to save at least the current page in some data structure.

That's the approach I take.  It has taken reporting from a potential crisis
here at our office, to a no-brainer.

For end-user reporting, we have a reporting tool that we developed for
another platform, and are porting to RB.  More on that later.

Hope this helps,
Tim



-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Youri
Sent: Friday, December 29, 2006 2:19 PM
To: REALbasic NUG
Subject: Re: Printing, Reports etc… with DB apps



I like that solution "à la Die Hard". Not for the report thought...

As a matter of interest, could you please develop a little bit more the
process you go throught?

Where do you place your Canvas in RB? (in a window, a container
control...)

How do you size the canvas. For instance if you want the output to fit
in a A4 paper sheet, what sort of calculation you have to perform to
size your canvas accordingly?

etc...


Sorry about hese trivail questions, but I have not touched the subject
of printing matter out of a RB app yet.


TIA,


Youri




Tim Hare wrote:
Draw everything with RB.

I wrote a set of classes to handle the details.  The actual
code to produce
a given report is pretty simple, but we get very nice quality
output.  And
the output scales perfectly to fit the page within whatever
paper size and
margins they select.  So the preview matches the output perfectly: logo,
boxes and shading, text styles, color, everything.

It's not a solution I would recommend to the casual developer,
but I find
that for more than just a quick and dirty report, I want
maximum flexibility
and complete control over the output.


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Youri
Sent: Thursday, December 28, 2006 12:14 PM
To: Real Basic List
Subject: Printing, Reports etc… with DB apps



Hi,


As a matter of interest (for a quite Newbie), what technic(s) are the
most popular among RB developers to print datas out of RB in
Database Apps?


For instance :

1 - For Printing Invoices, Delivery notes etc…

Do you create windows with Container Control that your print on demand?

Do you draw all the form using Graphics, Canvas etc…?

Do you use file template, like for instance a .rtf file with a set of
fields (ie <Name>) that you replace with RB and rely on Word,
OpenOffice
etc… to output?


2 - Here comes the difficult one : Reports with sub-totals etc…

Do you rely on export-import sequences using Excel?

Do you draw everything with RB?

???


I must admit, that IMHO, the biggest weakness of RB for developping DB
apps is the printing of reports (not to forget also the "listcontrol").



Best regards,


Youri
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.432 / Virus Database: 268.15.29/607 - Release Date:
12/28/2006 12:31 PM

--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.432 / Virus Database: 268.15.29/607 - Release
Date: 12/28/2006
12:31 PM

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.432 / Virus Database: 268.15.29/608 - Release Date:
12/29/2006 8:22 AM

--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.432 / Virus Database: 268.15.29/608 - Release Date: 12/29/2006
8:22 AM

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to