WEB print the relevant technical analysis
WEB print the relevant technical analysis
Print Web existing control technology into several options
Zidingxikongjian completed Print
Use IE comes with the realization WebBrowser Control Print
Use of third-party controls to achieve Print
On the following major aspects of the first two
First, Zidingxikongjian way
Zidingxikongjian way is to use tools such as VB or VC COM components generated by definition good print format of the source document so as to achieve Print Print. Only components will be generated and downloaded to the client registered, the client can be achieved in print.
Print is difficult definition format, how to analyze print sources. Comparison of the existing good method is the use of XML technology to fully solve the problem, using XML definition can be very easy to print objectives of the text, tables and other content format. However, the development requirements of programmers, more difficult.
Second, the use of Web Print WebBrowser
IE WebBrowser is the built-in browser controls, without users to download. This document is discussed by the WebBrowser control IE6.0 version of the technical content. Associated with the technical requirements are: Print the document generation, page setup, printing operations, such as the realization of several parts.
(A), print the document generation
1, the client script way
Client divided into VBScript, JavaScript, JScript several scripting language. IE in the development and application of the syntax to use JScript syntax, as it and JavaScript little difference, so can be called JavaScript (Below initials JS). Under normal circumstances, the main use JS to achieve DOM document analysis, DOM for Microsoft's model of a Web document, mainly used to achieve Web Scripting.
JS sources can be analyzed by the content of pages, will be to print the page elements extracted to achieve print. By analyzing the content of the source document, the objectives of print documents can be generated.
Advantages: client independently accomplish goals print documents generated, reduce server load;
Disadvantages: the analysis of source documents and complicated to operate, and the source print contents of the document must be agreed;
2, the server-side approach procedures
Server-side procedures, mainly used in the background code read from the database print source, print production target document. When generated pages, it should give due consideration to the use of CSS to achieve mandatory paging control.
Advantages: can generate very rich printing goal documents, the contents of the documents goal controllable strong. The print is obtained from the database, generating relatively simple operation;
Disadvantages: server-side load more;
(2), Page Setup
Page Setup mainly refers to print a document setting page margins, headers, footers, paper, and so forth. Page Setup will directly affect the layout to print documents generated effects, and it has therefore generate and print documents are closely related. For example: the number of rows form, size, location, font size.
The technology is the use of the existing built-in print templates IE6.0 way to control page settings, which can print on the document have a very big goal of the impact. Print templates can control the page margins, header, footer, parity and so on page content, and user settings can be made, but also can be sent to the server settings.
Print template technology can set the preview window and print format, the maximum impact on target document and print results.
(C), the realization of printing operation
Implementation of this feature is mainly a function of the use WebBrowser control interface to achieve Print, Print Preview (default), page settings (default).
<Object ID = 'WebBrowser1' WIDTH = 0 HEIGHT = 0
CLASSID = 'CLSID: 8856F961-340A-11D0-A96B-00C04FD705A2'>
WebBrowser1.ExecWB (6,1);
/ / Print Settings
WebBrowser1.ExecWB (8, 1);
/ / Print Preview
WebBrowser1.ExecWB (7,1);
Third, the project will use the Print programme
Server-side procedures, Print preview interface calls, the following example, the major projects in the reference: document pageErrorPrint.aspx.vb
Calling the main page
Function PrintPage (iPageIndex, strQuery)
(
Var strURL;
StrURL = "PageErrorPrint.aspx? PageIndex =" + iPageIndex + "& QueryString =" + strQuery;
WinPrint = window.open (strURL ,""," left = 2000, top = 2000, fullscreen = 3 ");
)
Print page in the HTML preview control
<SCRIPT Language="javascript">
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>
Procedures first
'First of all forms statement containers
Protected WithEvents phContainer As System.Web.UI.WebControls.PlaceHolder
'Each of the records of the number of forms
Private Const ItemPerTable As Integer = 20
Implementation of key parts
'Create a form consistent with the requirements of Print
NewPrintTable tabPagePrint = ()
'Add to the first table in this form
Call AddTableTitle (tabPagePrint)
'Initialization Recorder
I = 0
IItemIndex = iStartPoint
For Each clsItem In clsAllData.ErrorCollection
If i> 0 And i Mod ItemPerTable = 0 Then
'Add to page form controls
PhContainer.Controls.Add (tabPagePrint)
'In the pages of adding a newline
Call AddPageBreak ()
'Create a new round of the form
NewPrintTable tabPagePrint = ()
Call AddTableTitle (tabPagePrint)
End If
'Records will be added to the table
Call AddItemToTable (iItemIndex, tabPagePrint, clsItem)
IItemIndex iItemIndex + 1 =
I = i + 1
Next
'Add to page form controls
PhContainer.Controls.Add (tabPagePrint)
Support function
'Function: Add page newline
Private Sub AddPageBreak ()
Dim ltBreak As LiteralControl
LtBreak = New LiteralControl ( "<p style='page-break-before:always'>")
PhContainer.Controls.Add (ltBreak)
End Sub
'Function: to create a form consistent with the requirements of Print
Private Function NewPrintTable () As Table
Dim tabSrc As New Table ()
TabSrc.Width = Unit.Percentage (100)
TabSrc.Attributes (the "border") = "1"
TabSrc.CellPadding = 4
TabSrc.CellSpacing = 0
TabSrc.BorderWidth = Unit.Pixel (2)
TabSrc.BorderColor = Color.Black
TabSrc.Style.Add ( "FONT-SIZE", "12px")
NewPrintTable = tabSrc
End Function
From CSDN Forum
Tags: web








0 Comments to “WEB print the relevant technical analysis”
No Comments. Send your comment.
Leave a Reply
You must be logged in to post a comment.