PRINT REPORT

Everything else that doesn't fall into one of the other PB categories.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. 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

Current PB Projects:
[Construdata 2003 - 30%]
[Step by Step - 50%]
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

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...
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Kale.
Old programmers never die... They branch into a subroutine...
should that be:

Old programmers never die, they just GOSUB without RETURN! ? :)

--Kale

In love with PureBasic! :)
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Post by Rook Zimbabwe »

I have been tweaking this a bit for PB4

Remember font size is divided by 25.7 so...

Code: Select all

;Super Printer - DPI indepent print
;by Rui Carvalho - 2003
;
;Part of GIA - Lift Management Software
;Freeware
;***************************

;rui-carvalho@bigfoot.com

Declare ycm(x.f)
Declare xcm(x.f)
;
;Original printer code by Fred
;
    LoadFont(0, "Arial", 250) ; 1cm tall
    LoadFont(1, "Arial", 125) ; .5cm tall
    ; the font size number divides into what appears to be PrinterPageSize() 
    ;
    
Result = DefaultPrinter()
 
;If PrintRequester() ; *** ENABLE THIS AND THE LAST ENDIF if you want printrequester

  If StartPrinting("PureBasic Test")

    If StartDrawing(PrinterOutput())

      DrawingFont(FontID(1));4cm font size

        ; locate at 5cm by 5,5cm
        DrawText(xcm(5), xcm(5),"PureBasic Printer Test 44 pt")

          DrawingFont(FontID(0)); 1.8 cm font size

          DrawText(xcm(1), ycm(10),"PureBasic Printer Test 2 18 point")

      If LoadImage(0, "C:\Program Files\PureBasic\DEVEL\BMFREEPOS\logo1.bmp"); The logo bitmap is bigger
    ; ResizeImage(0, ) ; resize image for 6cm by 2cm
      ;DrawImage(0, xcm(1), ycm(1),xcm(6), ycm(2)); draw image at 1cm by 1cm
      Else
      MessageRequester("", "2", 0)
      EndIf


  Box(xcm(0), ycm(0), xcm(4), ycm(4)); draw a 4cm by 4cm square

  StopDrawing()
    EndIf

    StopPrinting()
  EndIf
  ;
; EndIf ; *** ENABLE IF YOU WANT PRINT REQUESTER



;**** the trick !!!! ****

Procedure xcm(x.f)

result = x * (PrinterPageWidth()/20.5) ; 21cm A4, 20.5 LETTER
ProcedureReturn result

EndProcedure


Procedure ycm(x.f)

result = x * (PrinterPageHeight()/26.7) ; 29,7cm A4, 26.8 LETTER, LEGAL?
ProcedureReturn result

EndProcedure

Post Reply