Technical Analysis of Web Printing

zhaozj2021-02-16  146

Technical Analysis of Web Printing

Existing Web Print Control Technique is divided into several scenarios Custom controls Complete printing using IE's own WebBrowser control implementation printing, using third-party controls implementation printing the following main two contents 1. Custom control mode custom control method That is to generate a COM component using a tool such as VB or VC, and analyze the printed source file with the defined print format 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. Second, 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). In general, the JS is mainly used to implement the analysis of the DOM document, and the DOM is a web document model proposed by Microsoft, mainly 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); 3 main page document calling 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