Delphi Development Web Application Printing component

Source: Internet
Author: User
Tags integer

I. Overview

In recent years, with the popularization and popularization of the Internet, the traditional stand-alone mode and the C/s mode in the domain are increasingly unable to meet the requirements of information sharing. Therefore, the development of a new browser-based b/S application is presented. The new development program with its client maintenance-free, configuration-free, the program can be updated according to the information of the server can automatically update, server-side multi-tier mode should improve processing efficiency and security is increasingly favored by the vast number of application developers. Become a new development direction for application development. On the Windows platform, people use ASP to develop the display interface of services, while using components to encapsulate business rules, it is not uncommon to use various tools for component development in various magazines. But the introduction of print group development is not seen?

Second, the Assumption

The requirements for a Web print component are mentioned in the development of an information management system for a unit, and some of the bills in this system need to be printed. In this way, how to set up these bills is a problem we must solve.

To print some user-requested notes or other text or picture information on the client, there are two ways: one is to use Delphi's active form to generate the client interface, downloaded and installed by the browser, and run on the client. (This method is more commonly used in the development of multiple background databases.) This approach is used in many new versions of financial software in the country, the disadvantage is that the developer's requirements are too high, and the other is to develop a component to install on the client side, then generate the VBScript script from the server, run it on the client, create the corresponding Component object, and use the Component object for the printing operation. (This approach can be easily invoked by users who are familiar with VBScript or JavaScript scripting languages as long as the client's COM component is developed)?

Third, realize

First, run Delphi 5.0; Select New in the File menu, select the ActiveX page in the pop-up dialog box, and select ActiveX Library to create the ActiveX libraries. Then add a Automation object to the new library. Procedure above. Fill in the component name Prttest3 in the Automation Object Wizard dialog box, click OK.

Then, in the pop-up prttest3.tlb window, select Iprttest3. Right-click to add a Isinit property with a type of long. Continue to add the following 5 method:

  procedure prtcustompage(pagewidth: integer; pageheight: integer);
    safecall;
   procedure prtstart; safecall;
   procedure prtnewpage; safecall;
   procedure prtend; safecall;
   procedure prtdrawline(x1: integer; y1: integer; x2: integer; y2:
    integer; linewidth: integer); safecall;
   procedure prtsetfont(const fontname: widestring; fontsize:
    integer); safecall;
   procedure prttextrect(valign: integer; halign: integer; rectleft:
    integer; recttop: integer;rectright: integer; rectbottom:
    integer; const printstring: widestring); safecall;

Their meaning is:

Prtcustompage is used to set up custom paper. Parameters passed in Customize the width and height of the paper.

Prtstart is used to initialize the printer. If the initialization succeeds, the attribute Isinit is set to true, whereas false.

Prtnewpage is used to change the printer page.

Prtend ends the print task.

Prtdrawline is used to draw a line on the page. (X1,Y1) as the starting point. (X2,Y2) is the termination point. LineWidth is the width of the print line.

Prtsetfont is used to set the font name and size of the print.

Prttextrect the specified string for the output in the specified box.

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.