Technical Analysis of Web Printing

xiaoxiao2021-03-06  40

"Related technical analysis of web printing"

Published: 2004-10-4

Text / Xie Kang's WEB development must face a common problem, that is, print. Indeed, relative to Windows desktop applications, Web applications have various restrictions, and technicians often encounter users or such needs during project development. People who have done desktop applications will be very familiar with crystal reports. Report controls such as Active Report, which not only has a simple and flexible design interface, but also a very powerful report function, which can meet the printing needs of various reports. WEB applications can only seek other solutions because of its special rendering. Now let's analyze the currently formed Web Print Scheme: Existing Web Print Control Technology is divided into several options: one. Custom Control Complete Print WebBrowser Control Printing Utilized IE To implement print 1 Source files to implement print. Printing on the client is only available on the generated component to download and register to the client. The difficulty is mainly to define the print format, how to analyze the printed source file. The existing preferred method is to use XML technology to completely solve problems, using XML to be very easy to define the text, tables, and other contents of the print target. However, the development requirements of programmers are high, and the difficulty is relatively large. 2. Using WebBrowser to Implement WebBrowser is the browser control of IE, no user downloads. The discussion of this document is the technical content about the IE6.0 version of WebBrowser control. The technical requirements associated with it are: the generation of print documents, page settings, and implementation of print operations. (1) Printing the generation of documents 1. Client scripting client scripts are divided into VBScript, JavaScript, JScript several scripting languages. Developing the syntax used by the application in IE JScript syntax, because it is almost no difference in JavaScript, so it can be called JavaScript (Similar JS below). Under normal circumstances, the JS is mainly used to achieve the analysis of the DOM document, and the DOM is a web document model that Microsoft. It is mainly used to implement web scripting programming. Using JS to analyze the contents of the source page, extract the page elements you want to print and implement printed. By analyzing the contents of the source document, you can generate a print target document. Advantages: The client independently completes the generation of print target documents, mitigating server load; disadvantages: The analysis operation of the source document is complex, and the print content in the source document must be agreed; 2. Server-side program mode server-side program is mainly used The background code reads the print source from the database to generate a print target document. When the page is generated, it should also be appropriate to consider using CSS to implement forced paging control. Advantages: You can generate a very rich print target document, and the content of the content of the target document is strong. Since the print content is obtained from the database, the generation operation is relatively simple; shortcomings: server-side load is relatively large; (2), page setting page settings mainly refer to page margins, headers, footer, paper, header, footer, paper Wait for content. Page settings will directly affect the generation effect of print document layout, so it has a close relationship with the generation of print documents. For example: the number of lines, sizes, positions, and fonts of the table. The existing technology is to control the page settings using the IE6.0's built-in print template, which can have a very large impact on the print destination document. The print template can control the page distance, header, footer, parity page, and other content, and you can get the user's settings, and you can send the setting to the server side.

Print Template technology You can customize the preview window and print format to maximize the target documentation and printing. (3) Implementation of printing operation This function is mainly used to implement print, print preview (default), page settings (default), page settings (default).

// Print WebBrowser1.execwb (6, 1); // Print Setting WebBrowser1.execwb (8 , 1); // Print preview WebBrowser1.execwb (7, 1); vb call the main page file function PrintPage (iPageIndex, strQuery) {var strURL; strURL = "PageErrorPrint.aspx PageIndex =?" iPageIndex "& QueryString =" strQuery; winPrint = window.open (strURL, "", "left = 2000, TOP = 2000, Fullscreen = 3 ");} Preview of the Print Page HTML