I've tried to mirror the way PB does it's window/gadgets creation. To create a report you simply have to do this...
Code: Select all
If xp_CreatePrintJob(#PrintMain, "Purebasic Invoice")
; Create a sample invoice.
If xp_AddPage(1)
;
xp_AddImage(#pLogo, 10, 60, -1, -1, "", ?PBLogo)
xp_AddText(#pCompanyName, xp_GetX(#pLogo) + xp_GetWidth(#pLogo) + 50, 10, 1400, 180, "<fs18>Fantaisie Software")
xp_AddLine(#pCompanyDivider, xp_GetX(#pCompanyName), xp_GetY(#pCompanyName) + xp_GetHeight(#pCompanyName) + 20, xp_GetX(#pCompanyName) + xp_GetWidth(#pCompanyName), xp_GetY(#pCompanyName) + xp_GetHeight(#pCompanyName) + 20, 1)
EndIf
;
EndIf
Preview window? Yes, there is a preview window. So, once you have your report designed you only have to call...
Code: Select all
xp_Preview(#PrintMain)
The largest part of this code is the way text is handled. I've implemented formatting tags. So, you can change bold text, underline, etc... in the middle of a text block. No need to to have multiple text objects just to change formatting.
I like to think the text printing is pretty darn good. Line breaking is properly handled for multiple lines of text and you can center or right-align your text. This is handled via custom code so it takes into account all that nice formatting you do mid-line. So far, the formatting stuff is...
- 1. Bold text <b> </b>
2. Italicize Text <i> </i>
3. Underline Text <u> </u>
4. Font Size <fsXX> </fs>
5. Font Name <fnYYYYYYYYYY> </fn>
6. Font Color <fcXXXXXXXX> </fc>
7. Line Break <br>
8. Tab <tab>
9. Custom Tab Stops <tstopXX>
It took a lot of time to get the text to behave properly

You can have multiple pages for your report. The preview window will show them and all you to cycle through each page to see what it's like.
Images may be added by path or by address in memory so you can IncludeBinary your image and load it from there.
Please note that I use UseEC_OLEImageDecoder which can be grabbed from...
http://www.purebasic.fr/english/viewtop ... c&start=45
http://www.purearea.net/pb/download/use ... LE_2.3.zip
You can also create a 'custom' object and pass a procedure as one of the parameters. xPrint will call your procedure as needed and pass along the hdc, x/y/width/height and a couple other things so that you can do your own drawing. So if you're using a third part library for something like a barcode, you can draw it yourself through that procedure.
I welcome any extra ideas and info on any bugs you notice. As I said - there are two main ones - print preview doesn't scale properly and sometimes the border will not be completely drawn around text objects.
Oh, yeah, you can specify whether or not you want a border drawn around your text and whether you want a back color for the text area.
I'll continue working on this as I need it for work. If you find it useful, great

It's released under LGPL. Take it easy

http://www.seijin.net/Storage/Code/xPrint.zip