Preliminary study on the development of print components on web applications

zhaozj2021-02-08  277

I. Introduction

In recent years, with the popularity and promotion of the Internet, traditional stand-alone mode and C / S model in the LAN have become more and more unable to meet the requirements of information sharing. Therefore, a new development method based on the browser-based B / S is enrolled. The new development plan is automatically updated automatically based on its client's maintenance, free of configuration, and the program can automatically update the upgrade according to the information of the server; the server-side multi-layer mode should improve the efficiency and security of the processing. It is optimistic about it. Become a new direction of development development. On Windows's platform, people use ASP to develop service display interfaces, and use components to package business rules, and use various tools to use a variety of magazines to develop components. It is also uncommon. But introducing the printing group is not very much. The author hopes to throw the jade from a little experience in the development of printing components.

Second, the idea

The web print component requires that some of the bills in this system need to print in a certain unit development information management system. In this way, how to set these bills into problems we have to solve.

There are two ways to print some of the tickets or other text or image information on the client, one is to generate the interface of the client using Delphi's Active Form, and is downloaded by the browser and runs on the client. (This approach is more common in the development of multi-bache database. There is a method in China's new version of financial software. Its disadvantage is that the requirements for developers are too high), the other is to develop a component in the customer. End Installation, then generate the VBScript script by the server, run, create the corresponding component object; use the component object to make a print operation. (This method is as long as the client's COM component development is completed, as long as it is familiar with the VBScript or JavaScript scripting language to be convenient). This article we mainly discuss the second way.

Third, realize

First, run Delphi 5.0; select New in the File menu, select the ActiveX page in the pop-up dialog box, select ActiveX Library to create an ActiveX library. Then, add an Automation Object to the newly created library, and the operation steps are. Fill in the component name PrtTest3 in the Automation Object Wizard dialog; click OK.

Then, in the pop-up PrtTest3.tlb window, select IPRTTest3. Click Right click to add an isinit's Property, the type is long. Continue to increase the following five Method:

PROCEDURE PRTCUSTOMPAGE (PageHeight: Integer; SaFECALL;

PROCEDURE PRTSTART; SAFECALL;

PROCEDURE PRTNEWPAGE; SAFECALL;

PROCEDURE PRTEND; SAFECALL;

Procedure procrawline (x1: integer; x2: integer; y2: integer; linewidth: integer;

Procedure PrtSetfont (const fontname: WideString; Fontsize: integer; SaFECALL;

PROCEDURE PRTTEXTRECT (Valign: Integer; Rect: Integer; RectTop: Integer; Rectright: Integer; RectBottom: integer; const printstring: wideString;

They mean: PRTCUSTompage is used to set custom paper. Introduced parameters customize the width and height of the paper. PrtStart is used to initialize the printer. If initialization is successful, the attribute isinit is set true, and it is false.

PrtneWPage is used to make the printer to change the page.

PRTEND ends the print task.

Prtdrawline is used to draw a line on the page. (X1, y1) is the starting point. (X2, y2) is the termination point. LINEWIDTH is the width of the print line.

PrtSetFont is used to set the printed font name and size.

PrtTEXTRECT is used to specify the specified string of the output in the box.

Fourth, call

Method for calling this component in the script:

(1) Create a print object using the CreateObject function.

(2) Call the PRTCUSTompage to specify the size of the custom paper (based on 0.1 mm). If, not a customized paper, do not need to call this process (ie, print the default paper size).

(3) Call PrtStart to initialize the printer. If the printer is initialized, it will be true, indicating the initialization success; otherwise, indicating that the printer is busy or other applications are using the printer, initialization cannot succeed.

(4) Judging the Isinit flag. If true, continue the print segment.

(5) Execute the print segment. You can use the printer to display the text and output in the specified location.

(Note: All positions in the component are 0.1 mm. For example, .prtobject.prtdrawlien 0,0,1000, 1000 represents a straight line from the upper left corner (0, 0) mm to the lower right corner (100, 100) mm )

(6), the print task is ended by prtend.