Web embedded. Net printing Control

Source: Internet
Author: User
Tags ibm db2 print format
Web embedded. Net print control 20:46:19 smile ^ _ ^ @-mz7x/article/-mz7x-fohkji.html copy comments

XML-based precise printing of Web System reports

Wang chunhong he Zhilin

(Department of Computer Science and Technology, Yuncheng University, Yuncheng 044000, China)

 

Abstract: XML and its related technologies have gradually penetrated into all aspects of computer science. In view of the characteristics of XML, a method is provided to use XML to quickly and accurately print reports on clients in the B/S structure, the implementation process of this scheme on the Microsoft Asp.net platform is illustrated by the developed Bidding Management System of the Construction Project trading center of Yuncheng City Construction Bureau. This solution is simple, scalable, and easy to maintain.

Keywords: XML Web Printing Data Exchange Web Service web ticket Printing

Exact report printing of Web System Based on XML

(Chunhong-Wang Zhilin-He)

(Computer & Science Department of Yuncheng University)

 

Abstract: XML and its relevant technology have been found at all the levels of the computer science. by exploiting its features, a method of quick and exact report printing of sheet has been offered. this method has also been exemplified in the platform of Microsoft Asp.net by an example of bidding system designed for Yuncheng construction trade of center, Bureau of urban construction. the result shows that this method is simple, and easy to expand and maintain.

Keywords: XML Web Printing Data Exchange Web Service web printing of receipt

 


0 Introduction

In recent years, with the popularization and promotion of broadband networks, local area network-based C/S structure should be more and more unable to meet the needs of enterprise informatization, browser-based B/S structure applications are becoming more and more popular. B/S-structured application clients are free of installation, configuration-free, maintenance-free, and upgrade. The server uses a multi-layer mode to separate the presentation layer, business logic layer, and data layer, this greatly improves the development efficiency and data security. At present, applications based on B/S structure have become the mainstream of software development. However, the B/S structure also has some disadvantages, such as flexible web report printing implementation, especially the precision setting of some invoices is not easy to implement!

The existing web printing control technology is divided into several solutions: (1) printing with custom controls; (2) printing with the webbrowser control provided by IE; (3) use third-party controls for printing. Using IE printing is too simple to meet complicated ticket printing requirements. using third-party controls will often require a certain amount of cost and make the system installation and deployment complex. The custom control method is to use tools such as VB or VC to generate COM components, or use. Net to generate. NET components, and use the defined print format to analyze and print source files for printing. Using XML, you can easily define the format of the printed target text, table, and other content to easily implement various complex printing needs. This article describes how to build a. Net printing component based on XML technology on the. NET platform to implement precise web system printing.

1. xml features

XML has become a good tool for describing various complex data, especially structured data, with its good data structure and scalability. In addition, XML allows you to create special data for specific applications. It has the following features:

A) Strict standardization and clear Semantics

B) data sharing and reuse

C) excellent scalability

D) platform independence

Based on the above features, it is conducive to good XML scalability and platform independence. You can define all the format control labels we need, the printer is directly controlled from the client based on the printing format defined on the server side, so as to implement cross-platform general report printing.

2. System Principle

With the powerful custom functions of XML, we can easily customize the format control labels we need.

The server performs dynamic encoding and transmits the code to the client through the Web server. Then, the client parses the format and directly controls the printer to print the required reports based on the printing format defined by the server. 1:

Figure 1 System Principle Design

 

We adopt. net Framework winform is used as a printing control, which can be directly embedded into the web page for printing, but the control embedded in the web page cannot be directly connected to the database, therefore, only XML files can be used for intermediate data exchange, and data transmission is performed through the default port 80 of the common web server. Of course, we can also use the web service that transmits data using soap to extract data directly from the database. In principle, it should belong to the same type of technology as the XML we adopt.

Most databases support data query and conversion in XML format, such as SQL Server 2000, Oracle 9i, IBM DB2, and other large relational databases. You can directly convert XML data with simple settings. If the database does not support direct XML data conversion, you can also use JSP, ASP, PHP, and other server-side scripting programs for script conversion.

The client does not need any special settings. You only need to install a 21 M. NET Framework distribution package, and then directly open the webpage to work. There are no operating system restrictions, from Windows 98 to Windows XP.

Because the XML standard data format is used as the intermediate data exchange, this solution is very scalable, for example, the client. net controls can be directly replaced by client applications written in Java Applet, activx, VB, and VC. You can also choose to use web servers such as IIS or Apache. You can also use any database. Including SQL Server, Oracle, or access.

Because common Web servers are used to transmit data, mature web encryption technologies such as SSL Secure Sockets can be directly used. At the same time, the XML data algorithm can be encrypted and decrypted on the client to ensure the transmission security.

3. System implementation

First, we use VB.net to design an XML print control, which can load XML report files from local or web files or even Web Services, and then according to the definition in the XML report, extract the lines, boxes, and text in the report to form a printdocument for preview or printing.

Copy the generated dll Control to the directory of the web system, and use <Object>

The tag inserts the control into the web page, and uses JavaScript to pass the XML report file dynamically generated by the Web server to the print control in the form of parameters, so as to achieve flexible and accurate printing on the Web page!

The following uses the Network Office System of the Construction Project Transaction Center of Yuncheng City Construction Bureau as an example to describe how to use the. NET printing Control Based on XML to implement Custom reports for bidding archives. First, we use ASP. NET to build a web Network Office platform to achieve basic file management and bidding process management. Figure 2 shows a project report page! Because the information on this page needs to be printed and archived, It is embedded on this page. net report printing control, and pass the XML report file generated on the page to the printing control through a Javascript script. Click the print button to open the print preview interface of the project report table, see figure 3.

Figure 2

Figure 3

 

The XML report format for printing is as follows:

<? XML version = "1.0" encoding = "UTF-8"?>

<Root>

<Reportsetting>/* Report page setting */

<Landscape> true </landscape> <papertype> A4 </papertype>

<Paperwidth> 2100 </paperwidth> <paperheight> 2970 </paperheight>

<Leftmargin> 100 </leftmargin> <rightmargin> 100 </rightmargin>

<Topmargin> 100 </topmargin> <bottommargin> 100 </bottommargin>

</Reportsetting>

<Reportdetail>/* report content */

& Lt; text x = "380" Y = "65" fontname = "" fontsize = "20"

Fontcolor = "black" B = "true" I = "false" u = "true"> Yuncheng construction engineering report table </text>

<Text x = "100" Y = "120" fontname = "" fontsize = "12" fontcolor = "black" B = "true" I = "false" u =" true "> date: </text>/* define text */

...

<Rect x = "90" Y = "160" width = "980" Height = "540" border = "2" bordercolor = "black"/>/* define the moment type */

...

<Line X1 = "650" Y1 = "460" X2 = "1070" y2 = "460" border = "1" bordercolor = "black"/>/* define line */

...

<Data x = "510" Y = "430" fontname = "" fontsize = "12" fontcolor = "black" B = "true" I = "false" u =" true "> office building </text>/* define printed data */

...

</Reportdetail>

</Root>

 

Read XML reports and parse and print control functions

Private sub pageprint (byval sender as object, byval eV as printpageeventargs)

Dim G as graphics = eV. Graphics

Dim lastpage as Boolean = false

Dim pntelement as xmlprint. printelement = nothing 'Declares print resolution class

Dim node as xmlnode

For each node in DOC ("root") ("reportdetail"). childnodes

'Load the XML report file and parse the Report Content

Pntelement = xmlprint. parser. createelement (node)

'Call the parser to generate the corresponding object

Try

Lastpage = pntelement. Draw (g)

'Whether paging is required

Catch ex as exception

Me. lblmsg. Text = ex. Message

'Whether paging is required

End try

Next Node

Ev. lastpage = lastpage

End sub

 

The code for the implementation function of draw lines in the report is as follows:

Public class line inherits pntelement

'Line-drawn functions in the XML report parsing class

Public sub new (byval line as xmlnode)

_ Node = line 'refers to the input print data, that is, the node of an XML

End sub

Public overrides function draw (byval G as graphics) as Boolean 'draw line function

Dim s as string

Dim slgborder as single

S = _ node. attributes ("bordercolor"). innertext)

Slgborder = single. parse (

_ Node. attributes ("border"). innertext)

Dim pen as new

Pen (color. fromname (s), sglborder) 'defines the paint brush

Dim x1, x2, Y1, Y2 as single 'extracts coordinates from XML


X1 = single. parse (_ node. attributes ("X1"). innertext)

X2 = single. parse (_ node. attributes ("X2"). innertext)

Y1 = single. parse (_ node. attributes ("Y1"). innertext)

Y2 = single. parse (_ node. attributes ("Y2"). innertext)

G. drawline (pen, X1, Y1, X2, Y )'

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.