Hi Fangbeast
I'm sorry, I've been so busy lately I've not been much help at all. But your programs starting to look pretty
good.
As to printing. I use and really like these two by ABBKlaus
Check out Printer_Lib110
http://www.purebasicpower.de/?PrinterLib
Also check out PurePDF
http://www.purebasicpower.de/?PurePDF
They both work real great for printing to paper or to PDF. The only problem I found, is that the PurePDF lib
does not work with PB5.10. But it works great by using the included code in the examples directory.
Just don't install that lib, and include this at your codes beginning:
Code: Select all
#PurePDF_Include=1
XIncludeFile #PB_Compiler_Home +"Examples\PurePDF\PurePDF.pb"
And in PurePDF.pb in the examples directory. Look for Procedure.l ipdf_ASCII85_Decode ana change the
line to the following.
Code: Select all
Procedure.l ipdf_ASCII85_Decode(*InputBuffer,InputLength,*OutputBuffer,*OutputLength)
Protected tuple.q,c.l,count.l,err.l,*IPos,*OPos,i.l
The PurePDF code and PrinterLib have to be told where to print. So the following is an example template program
that can be used to help you with text placement. Once you start using it, it's not bad at all. The pdf program
just uses different command names, and is coded very similar. The first part of this code finds your printer,
and then it prints the template.
Code: Select all
#MR_SIMPLESILENT0 = $C0 ;this gives you the silent ok box when using MessageRequester
Global selprn$
;selprn$="WorkForce 610(Network)"
Procedure.s check_startup_printer(selprn$)
;First check if there is a printer. Then check if there is more than one printer.
;If there is, allow printer selection.
If selprn$="Print to PDF"
ProcedureReturn selprn$
Else
printer_exist=0
Options=#PRINTER_ENUM_LOCAL|#PRINTER_ENUM_CONNECTIONS;|#PRINTER_ENUM_REMOTE
EnumPrinters_(Options, 0, 1, #Null, 0, @dwNeeded, @dwReturned)
;Debug GetLastError_()
If dwNeeded
*buffer = AllocateMemory(dwNeeded)
EnumPrinters_(Options, 0, 1, *buffer, dwNeeded, @dwNeeded, @count)
;FreeMemory(*buffer)
EndIf
If Trim(dfpn$)=""
;this gets default at startup, but if you change the printer, it stays selected until you restart program
;or reselect another printer.
dfpn$=Print_GetDefaultPrinter()
EndIf
If count=1; if count = 1 there is only one printer found
i=count
pointer=PeekI(*buffer+(i-1)*SizeOf(PRINTER_INFO_1)+OffsetOf(PRINTER_INFO_1\pName))
pn$=PeekS(pointer)
;Debug pn$
If pn$=selprn$
printer_exist=1
EndIf
FreeMemory(*buffer)
If printer_exist=1
ProcedureReturn selprn$
Else
;your cfg printer does not exists. changing to system default found printer
selprn$=dfpn$
; CreateFile(1,pp$+"printer.cfg")
; WriteStringN(1,"Printer:"+selprn$)
; CloseFile(1)
ProcedureReturn selprn$
EndIf
EndIf
If count>1
For i = 1 To count
pointer=PeekI(*buffer+(i-1)*SizeOf(PRINTER_INFO_1)+OffsetOf(PRINTER_INFO_1\pName))
pn$=PeekS(pointer)
;Debug pn$
If pn$=selprn$
printer_exist=1
Break
EndIf
Next
FreeMemory(*buffer)
If printer_exist=1
ProcedureReturn selprn$
Else
;your cfg printer does not exists. changing to system default printer
selprn$=dfpn$
CreateFile(1,pp$+"printer.cfg")
WriteStringN(1,"Printer:"+selprn$)
CloseFile(1)
ProcedureReturn selprn$
EndIf
EndIf
If count<1
FreeMemory(*buffer)
MessageRequester(" Printer Error Message", "Can Not Locate Printer! Prints to PDF Only", #PB_MessageRequester_Ok|#MR_SIMPLESILENT0|#MB_TOPMOST|#MB_SYSTEMMODAL)
selprn$="Print to PDF"
dpn$=selprn$
ProcedureReturn selprn$
EndIf
EndIf
EndProcedure
;-
Procedure AP_PSA(poscnt)
If Print_OpenPrinter(selprn$,"PAPERSIZE="+Str(#DMPAPER_LETTER)+",ORIENTATION="+Str(#DMORIENT_PORTRAIT))
;When paperHeight and paperWidth are specified, paperSize shall be ignored.
Print_StartPrinting("MyData")
Print_Font("Arial",10)
x=0
;Horizontal Lines
For z=0 To 240 Step 10;210 is the max x position 'line' that can be printed.
Print_Text(x,z,Str(z))
Print_Line(x,z,210,0)
Next z
;Vertical Lines
For z=0 To 240 Step 10
Print_Text(z,5,Str(z))
Print_Line(z,0,0,240)
Next z
Print_Line(70,250,5,0)
Print_Line(70,250,0,5)
Print_Font("Arial",16)
Print_Text(70,250,"70,250 PB Printing Template")
;If y>240 ;set point where you want new page set.
;Notes: You should only use Print_NewPage() if you intent to print on the next page.
;You can even just print a space. But if you don't, then it will not print anythings.
; Print_NewPage()
; Print_Text(5,208," ");:y=y+3
While WindowEvent():Wend;needed or printer locks up
; y=4
;EndIf
;Next pos
;If y=4
; Print_EndDocPrinter() ; this stops and ends the print job if nothing to print.
;Else
Print_StopPrinting()
;EndIf
Else
err$=Print_GetLastError()
MessageRequester(" Print_StartPrinting()",err$,0)
EndIf
While WindowEvent():Wend;needed or printer locks up
EndProcedure
;{- Enumerations / DataSections
;{ Windows
Enumeration
#Window_0
EndEnumeration
;}
Define.l Event, EventWindow, EventGadget, EventType, EventMenu
;}
Procedure OpenWindow_Window_0()
If OpenWindow(#Window_0, 450, 200, 400, 400, "Window_0", #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_MinimizeGadget|#PB_Window_TitleBar)
EndIf
EndProcedure
OpenWindow_Window_0()
selprn$=check_startup_printer(selprn$)
poscnt=1
AP_PSA(poscnt)
;{- Event loop
Repeat
Event = WaitWindowEvent(5)
Select Event
; ///////////////////
Case #PB_Event_Gadget
EventGadget = EventGadget()
EventType = EventType()
; ////////////////////////
Case #PB_Event_CloseWindow
EventWindow = EventWindow()
If EventWindow = #Window_0
CloseWindow(#Window_0)
Break
EndIf
EndSelect
ForEver
;
;}
Hope that provides some help for you.
yrreti