[Pb] How to customize the printing page length in Pb

Source: Internet
Author: User
Tags printable characters

----

When the data window of continuous paper printing is used, the page length needs to be customized to ensure that the printer runs correctly without manual intervention to achieve continuous printing. In PB, an external function must be called to customize the paper length, which is cumbersome. This article introduces a method to directly control the printer and easily set the page length.

----

I,
Prerequisites

----

The communication between the computer and the printer is carried out using ASCII codes. The standard ASCII codes include printable and non-printable characters (control codes). The printer uses control codes to customize the printer. Most printer commands use the control code escape as the first sequence of their command sequence. The following describes the sequence of instruction codes used in this article:

Set line feed (line spacing)

1/8 inch

ASCII

Code
ESC 0

Decimal code

27 48

Set the page length in the unit of behavior

ASCII

Code
Esc c n

Decimal code

27 67 n

Where

N indicates the number of rows per page (1-127)

----

II,
Transmission of control codes in pb and implementation of custom page lengths

----

In PB, the control code is sent to the printer through the Printsend function (printjobnumber, string, {zerochar. Parameters are defined as follows:

Printjobnumber:

Print the job number returned by the printjob () function;

String:

Control string, using ASCII code;

Zerochar:

Used to replace the number 0 in string;

----

Because 0 in the string terminates the string, if the string
If it contains 0, other characters must be used to indicate 0. The zerochar parameter is used for this purpose. When PB sends a control string to the printer, the replacement character zerochar is converted to 0.

----

The following is a specific program for completing the customization page to print data windows (the customization page is 2.75 inch ):

Long ll_job

Dw_print.reset ()

Ll_job = printopen ()

If ll_job =-1 then

Messagebox (gs_title ,"

Printer not ready ")

Return

End if

//

Custom line spacing: 1/8 inch

PrintSend (ll_job, CHAR (27) + CHAR (48 ))

//

Set the page length to 22 rows

PrintSend (ll_job, CHAR (27) + CHAR (67) + CHAR (22 ))

Printdatawindow (ll_job, dw_print)

Printclose (ll_job)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.