Restored from previous forum. Originally posted by Num3.
 Originally posted by Num3

Does anyone have a code sample for a report system?
I'm finding a bit of trouble setting page width & height for A4.
I'm currently using a window with a bitmap to preview the report and then send it to the printer, but pagesize is ackword (size is not standard, it's using the size of the bitmap as output)
I'm almost giving up and going for the RPV report system.... 

Take a look at it: 
http://www.rpvreport.com
Help anyone ???
--
Kind Regards
Rui Carvalho
 
Note to myself and hint to all: 
 
;***************************
;Super Printer - DPI indepent print
;by Rui Carvalho - 2003
;
;Part of GIA - Lift Management Software
;Freeware
;***************************
;[url]mailto:
rui-carvalho@bigfoot.com[/url]
Declare ycm(x.f)
Declare xcm(x.f)
;
;Original printer code by Fred
;
If PrintRequester()
  
  If StartPrinting("PureBasic Test")
    
    If StartDrawing(PrinterOutput())
      
      DrawingFont(LoadFont(0,  "Arial", ycm(0.4)));4mm font size
      
      Locate(xcm(15),  xcm(5.5)); locate at 15cm by 5,5cm
      DrawText("PureBasic Printer Test")
      
      DrawingFont(LoadFont(0,  "Arial", ycm(1))); 1 cm font size
      
      Locate(xcm(10),  ycm(20))
      DrawText("PureBasic Printer Test 2")
      
      If LoadImage(0, "Data\PureBasiclogo.bmp"); The logo bitmap is bigger
        ResizeImage(0, xcm(6), ycm(2)) ; resize image for 6cm by 2cm
        DrawImage(ImageID(),  xcm(1), ycm(1)); draw image at 1cm by 1cm
      Else
        MessageRequester("", "2", 0)
      EndIf
      
      FrontColor(100, 100, 100)
      Box(xcm(2),  ycm(6), xcm(6), ycm(10)); draw a 4cm by 4cm square
      
      StopDrawing()
    EndIf
    
    StopPrinting()
  EndIf
EndIf
;**** the trick !!!! ****
Procedure xcm(x.f)
  
  result = x * (PrinterPageWidth()/21) ; 21cm A4
  ProcedureReturn result
  
EndProcedure
Procedure ycm(x.f)
  
  result = x * (PrinterPageWidth()/29.7) ; 29,7cm A4
  ProcedureReturn result
  
EndProcedure
;Tested with fineprintpdf in multiple DPI's
;and on Xerox DC440 laser printer
--
Kind Regards
Rui Carvalho
Old programmers never die... They branch into a subroutine...