Existing Web Print control technology is divided into several schemes

Source: Internet
Author: User
Tags print format requires
Web|web Printing | control
Existing Web Print control technology is divided into several schemes
Custom control finishes printing
Using IE self-webbrowser control to realize printing
Printing with third party controls
The following are mainly about the first two aspects of the content

One, custom control way
Custom control way is to use VB or VC tools to generate COM components, with a defined print format to analyze the printing source files to achieve printing. You can print on the client only if you download and register the generated components on the client computer.
The main difficulty is to define the print format and how to analyze the print source files. The best way to do this is to use XML technology to solve problems comprehensively, and XML makes it easy to define the format of text, tables, and so on that print the target. But the development of the programmer requires high, difficult than the larger.

Second, the use of WebBrowser to achieve web printing
WebBrowser is an IE-built browser control that requires no user downloads. This document discusses the WebBrowser control technical content for the IE6.0 version. Its related technical requirements are: the production of printed documents, page settings, printing operations, such as the implementation of several links.

(i), print the document generation
1. Client Script mode
Client script is divided into VBScript, JavaScript, and JScript scripting languages. The syntax used for developing applications under IE is JScript, which is almost indistinguishable from JavaScript, so it can also be called JavaScript (JS below). Generally, the main use of JS to achieve the analysis of DOM documents, Dom for Microsoft proposed a Web document model, mainly for the implementation of Web script programming.
The use of JS can analyze the content of the source page, will be printed on the page elements extracted to achieve printing. You can generate a print target document by analyzing the contents of the source document.

Advantages: The client completes the production of the printing target document independently and reduces the server load;
Disadvantages: The source document analysis operation is complex, and the source document print content to have the agreement;

2, server-side program mode
Server-side program mode, mainly using background code to read the print source from the database, to generate the print target document. When the page is generated, you should also consider using CSS to enforce paging control.

Advantages: can generate very rich content of the printing target document, the content of the target document is more controllable. Because the print content is obtained from the database, the generation operation is relatively simple;
Disadvantage: Server-side load is relatively large;

(b), page Setup
Page Setup is mainly about setting the margins, headers, footers, paper, and so on for the printed document. Page Setup will directly affect the production of printed document layout, so it is closely related to the generation of printed documents. For example: Table number of rows, size, position, size of the font and so on.
The existing technology is to use the IE6.0 built-in print template to control page settings, which can have a very large impact on the printing of the target document. The Print Template Controls page margins, headers, footers, odd and even pages, and can get the user's settings and send settings to the server side.
Print template technology can customize the preview window and print format to maximize the impact of the target document and printing effect.

(iii), the implementation of printing operations
This feature is implemented primarily by using the function interface of the WebBrowser control to achieve print, Print preview (default), page Setup (default).
<object id= ' WebBrowser1 ' width=0 height=0
Classid= ' CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 ' >
Print
WEBBROWSER1.EXECWB (6,1);
Print settings
WEBBROWSER1.EXECWB (8,1);
Print Preview
WEBBROWSER1.EXECWB (7,1);

Third, the project adopts the printing scheme
Server-side program mode, Print preview interface calls, for example, the main reference project: PageErrorPrint.aspx.vb file
Main Call Page
function PrintPage (ipageindex,strquery)
{
var strURL;
strURL = "Pageerrorprint.aspx?" pageindex= "+ Ipageindex +" &querystring= "+ strquery;
Winprint=window.open (strURL, "", "left=2000,top=2000,fullscreen=3");
}

Preview control in the print page HTML source
<script language= "JavaScript" >function print () {
document.write ("<object id= ' WebBrowser ' width=0 height=0
Classid= ' clsid:8856f961-340a-11d0-a96b-00c04fd705a2 ' ></object> ');
WEBBROWSER.EXECWB (7,1);
Window.opener=null;
Window.close ();}
</SCRIPT>



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.