networkthis
Programmer
I am looking for ideas to create a VFP solution that can print across multiple platforms: Currently have an exe that we run on Windows XP, Vista and Windows 7. We connect through Citrix, Windows Terminal Server 2003, 2008 and 2008 R2.
We have a .prg file that prints to a line feed printer. Each page printed is around 3.5" in height. Right now we have multiple solutions for multiple platforms. I am looking to make one solution that will work across all of them (Some of the solutions we were using only printed to LPT1.dos - I have updated them to work no matter where they are plugged in whether it is a USB cable, LPT1, etc...). For the Terminal Servers we use a Report to print - The line spacing doesn't seem to always come out correct with this solution (I would like to get rid of this solution). When the clients are running the exe locally or are connected to the Citrix Server we have a class that uses WINSPOOL.DRV and WIN32API to open spooling services, close spooling services and send the output directly to the printer - which works great!
If I can find a solution to print a file with a continuous print and no line feed, I can set the font size and it will print perfectly across all the pages.
Also, I just found this basic code which is a similar concept of what I would like to get to work on the Terminal Servers... Any ideas of how this could work running on a Terminal Server?
We have a .prg file that prints to a line feed printer. Each page printed is around 3.5" in height. Right now we have multiple solutions for multiple platforms. I am looking to make one solution that will work across all of them (Some of the solutions we were using only printed to LPT1.dos - I have updated them to work no matter where they are plugged in whether it is a USB cable, LPT1, etc...). For the Terminal Servers we use a Report to print - The line spacing doesn't seem to always come out correct with this solution (I would like to get rid of this solution). When the clients are running the exe locally or are connected to the Citrix Server we have a class that uses WINSPOOL.DRV and WIN32API to open spooling services, close spooling services and send the output directly to the printer - which works great!
If I can find a solution to print a file with a continuous print and no line feed, I can set the font size and it will print perfectly across all the pages.
Also, I just found this basic code which is a similar concept of what I would like to get to work on the Terminal Servers... Any ideas of how this could work running on a Terminal Server?
Code:
Declare Integer OpenPrinter In WinSpool.DRV As OpenPRN String, Integer @, Integer
Declare Integer StartDocPrinter In WinSpool.DRV As StartDocPRN Integer, Integer, String @
Declare Integer StartPagePrinter In WinSpool.DRV As StartPagePRN Integer
Declare Integer WritePrinter In WinSpool.DRV As WritePRN Integer, String, Integer, Integer @
Declare Integer EndPagePrinter In WinSpool.DRV As EndPagePRN Integer
Declare Integer EndDocPrinter In WinSpool.DRV As EndDocPRN Integer
Declare Integer ClosePrinter In WinSpool.DRV As ClosePRN Integer
Declare Integer GlobalFree In Win32API Integer
Declare Integer GlobalAlloc In Win32API Integer, Integer
Declare RtlMoveMemory In Win32API As Str2Heap Integer, String @, Integer
hPrinter =OpenST("Printer Name Goes Here")
=LineST(hPrinter, "Line # 1" + chr(10))
=LineST(hPrinter, "Line # 2" + chr(10))
=CloseST(hPrinter)
Clear DLLs
*********************************************************************************
* Open The Printer via Windows API *
*********************************************************************************
Function OpenST (NomePRN)
Store 0 To hPrinter, nRetornoAPI
&& Start Printer...
nRetornoAPI =OpenPRN(NomePRN, @hPrinter, 0)
If Empty(nRetornoAPI) Then
=Messageb([Printer "] + Upper(AllTr(NomePRN)) + [" not found.], 48)
Return
EndIf
oDocName =CreateObj("PChar", "Documento")
sDocInf =oDocName.sMem + Replic(Chr(0), 8)
=StartDocPRN(hPrinter, 1, @sDocInf)
=StartPagePRN(hPrinter)
Release oDocName, nRetornoAPI
Return hPrinter
EndFunc
*********************************************************************************
* Send Data to Printer via Windows API
*********************************************************************************
Procedure LineST (phPrinter, pcString)
nGuarda =Len(pcString)
nGuarda =WritePRN(phPrinter, pcString, nGuarda, @nGuarda)
If Empty(nGuarda) Then
=Messageb("Cannot send Data to the Printer.", 48)
=CloseST(phPrinter)
EndIf
EndProc
******************************************************************************
* Close the Printer Job
******************************************************************************
Function CloseST (hnPRN)
=EndPagePRN(hnPRN)
=EndDocPRN(hnPRN)
=ClosePRN(hnPRN)
EndFunc
*********************************************************************************
* Transform a DWord (Integer - 32 bits) in a String
*********************************************************************************
Function DWord2Str (pInteiro)
Return Chr(Mod(pInteiro, 256)) + Chr(Mod(pInteiro, 65536)/256) + ;
Chr(Mod(pInteiro, 256^3)/65536) + Chr(Mod(pInteiro, 256^4)/256^3)
EndFunc
*********************************************************************************
* Pointer Class
*********************************************************************************
Define Class PChar As Custom
hMem =0
sMem =Replic(Chr(0), 4)
Procedure Destroy
=GlobalFree(This.hMem)
EndProc
Procedure Init (lcString)
lcString =lcString + Chr(0)
lnSize =Len(lcString)
This.hMem =GlobalAlloc(0, lnSize)
If !Empty(This.hMem) Then
=Str2Heap(This.hMem, @lcString, lnSize)
This.sMem =DWord2Str(This.hMem)
EndIf
EndProc
EndDefine