Some Windows printer drivers and some Windows-oriented languages will not allow the PCL escape character pass-through to the printer since it is not a printable character in the Windows font set. (Visual Basic and the HP LaserJet III printer driver from the Windows for Workgroups disks are examples) The HP LaserJet III printer driver from the Windows 3.1 disks and the HP LaserJet 4 printer drivers do not have this problem unless used with a language like Visual Basic which causes the escape character to be removed on any printer driver. The Windows API contains a function specifically designed to avoid this problem by allowing the programmer to send any codes through the printer driver and the language that is sending data to the printer driver without interference. This API function is defined as follows:
short Escape(hdc,PASSTHROUGH, NULL, lpInData, NULL)
The PASSTHROUGH printer escape allows the application to send data directly to the printer, bypassing the standard print-driver code.
Note: To use this escape, an application must have complete information about how the particular printer operates.
ParameterDescription
PASSTHROUGH This function ID has a constant value of 19.
hdcHDC Identifies the device context.
lpInDataLPSTR Points to a structure whose first word (16 bits) contains the number of bytes of input data. The remaining bytes of the structure contain the data itself.
Returns
The return value specifies the number of bytes transferred to the printer if the escape is successful. This value is less than or equal to zero if the escape is not successful or not implemented.
Errors
If the function fails, the return value is one of the following:
ValueMeaning
SP_ERRORGeneral error.
SP_OUTOFDISKNot enough disk space is currently available for spooling, and no more space will become available.
SP_OUTOFMEMORYNot enough memory is available for spooling.
SP_USERABORTUser terminated the job through Print Manager.
Comments
There may be restrictions on the kinds of device data an application can send to the device without interfering with the operation of the driver. In general, applications must avoid resetting the printer or causing the page to be printed.
It is strongly recommended that applications do not perform actions that consume printer memory, such as downloading a font or a macro.
An application can avoid corrupting its data stream when issuing multiple, consecutive PASSTHROUGH escapes by not accessing the printer any other way during the sequence.
An application can guarantee that the PASSTHROUGH escape will be successful if it uses a "save" PostScript operator before sending PASSTHROUGH data and a "restore" operator after. Avoiding graphics device interface (GDI) functions between calls to the PASSTHROUGH escape and avoiding commands that cause a page to eject are other means to ensure that the escape will be successful.
The following is a sample Visual Basic program illustrating the use of this technique:
Option Explicit Const PASSTHROUGH = 19 Const PCLmacro = "&f" Const PCLOverlay = "y4X" Declare Function Escape Lib "gdi" (ByVal hdc As Integer, ByVal Esc As Integer, ByVal ncount As Integer, ByVal InData As String, ByVal outdata As Any) As Integer Sub Form_Load () list1.AddItem ("Form 100") list1.AddItem ("Form 101") End Sub Sub List1_Click () Dim PCL_Escape As String Dim Result As Integer Select Case list1.ListIndex Case 0 PCL_Escape = Chr(27) & PCLMacro & "100" & PCLOverlay Case 1 PCL_Escape = Chr(27) & PCLMacro & "101" & PCLOverlay End Select PCL_Escape = Chr(Len(PCL_Escape) Mod 265) & Chr(Len(PCL_Escape) \ 265) & PCL_Escape printer.Print "" Result = Escape(printer.hdc, PASSTHROUGH, 0, PCL_Escape, 0&) Select Case Result Case Is < 0 MsgBox "The PassThrough Escape is not supported by this printer driver.", 0 + 48 + 0 Case 0 MsgBox "An error occured sending the Escape Sequence.", 0 + 48 + 0 Case Is > 0 MsgBox "Escape successfully sent. Sending test printout to the printer.", 0 + 48 + 0 printer.Print "Test case of "; list1.text printer.EndDoc End Select End Sub
Comments:
file: /Techref/language/pcl/escwinapi.htm, 4KB, , updated: 2008/4/25 09:12, local time: 2024/11/19 07:30,
3.137.217.179:LOG IN
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://linistepper.com/Techref/language/pcl/escwinapi.htm"> Printing form images from printer-resident form storage in a programming language (e.g. Visual Basic.)</A> |
Did you find what you needed? |