×
Menu
Index

XppPDF.ch

 
 
ยท XppPDF.ch is a preprocessor file that will (almost) automatically convert all your existing reports to generate PDF files.
 
 
Including this preprocessor file at compile time, all your Gra... calls will be translated to an internal XbpPDF routine that will test for the type of object being passed as the first parameter. If this objec is a PDF object, than a PDF file will be created, if it is a Xbase++ object like a XbpPresSpace or a XbpPrinter, then normal processing will continue. With this approach minimal changes have to be made to your existing reports in order to use the XbasePDF class.
 
 

 
An example of how to use this new feature :
 
#include "xpppdf.ch"
 
PROCEDURE MAIN
 
     aSize := AppDeskTop():CurrentSize()
     aPos  := AppDeskTop():Currentpos()
     aSize[2] := aSize[2] - 45
     oDlg := xbpDialog():new(,,aPos,aSize)
     oDlg:Create()
 
     oPs := oDlg:DrawingArea:LockPS()
     oFont := xbpFont():New( oPs )
     oFont:Create('12.Times New Roman')
 
     oPdf := xbppdf():New()
     oPdf:Create("gra.pdf")
     oPdf:NewPage( , , , , ,1 )
 
     Report( oPdf )
     opdf:enddoc(.t.)
 
     Report( oPs )
 
     nEvent := 0
     do while nEvent <> xbeP_Close
          nEvent := AppEvent( @mp1, @mp2, @obr )
          obr:handleEvent( nEvent, mp1, mp2 )
     Enddo
 
Return
 
FUNCTION Report( ops )
 
     aAttra := array(GRA_AA_COUNT)
 
     aAttra[GRA_AA_COLOR] := GRA_CLR_WHITE
     GraSetAttrArea( ops, aAttra )
     GraBox( ops, {0,0}, aSize, GRA_OUTLINEFILL)
 
     aAttra[GRA_AA_COLOR] := GRA_CLR_YELLOW
     GraSetAttrArea( ops, aAttra )
     GraBox( ops, {80,100}, {220,300}, GRA_OUTLINEFILL)
 
     GraSetFont( ops, oFont )
     GraSetColor( ops, GRA_CLR_BLUE )
     GraStringAt( ops, {100,200}, "Hello world!" )
 
Return(.t.)
 
 
 
 
As you can see creating two different objects,a XbpPDF object ( oPdf ) and a PresSpace ( oPs ) you can call the same function (Report) and the preprocessor together with the XbpPDF class, will do the rest. The exact same report that is seen on the screen, is saved as a PDF file, and programming efforts is minimal.