The most headache of the application of the B / S structure can be that the report prints, since the browser can only be interacting as the user interface, so you cannot accurately control the client's printer. And many B / S structures often need to complete a very complex report print job. The page printing function that comes with IE can generally not meet the needs. Crystal Report is a commonly used and recommended solution, but if we only need some small-scale report printing, Crystal Report is huge, and customizable is not very good, its print In fact, the print function of IE is also used, and the printing effect cannot be accurately controlled, and you need to register it. So we discussed another way, simply, if you have any of the following needs, you can try this solution. Solution applicability 1. Remote data printing. The data that needs to be printed is not locally, and remote read must be performed. 2. Precisely control the printing effect, including page format, pagination, additional entry, table, and more. 3. For security considerations, you cannot connect directly to the database. The principle of the program is simple. It is very simple. Through XML powerful custom features, we can easily customize all our needs of our format control tags. After dynamic encoding in the server, pass the web server to the client, then on the client Format parsing, directly control the printer directly from the client to print out the reports we need from the client depending on the printed format defined by the server. Technical Selection Since the report print is more complicated, in order to accurately control the print format, the report print job can not be used in the way web browser page printing, and only the print job of the self-programming control client can be taken. Since the .NET Framework's WinForm can be embedded directly into the web page, we have this technology here, but please note that I don't mean that .NET WinForm is the only choice, in fact, you can use any client instead of it, for example Java Applet or ActiveX, even a normal application can be row. Do not allow direct connection to the database, so you can only use the XML file to perform the intermediate data exchange format, and data transmission is performed by the default 80 port of the ordinary web server. In fact, I can't find other ideal programs. Of course, Web Service may be a kind, but it uses SOAP transmission data. From the principle, the XML should be used as the same type technology. Address, I want to use the controlled components written by .NET, the advantage is that it does not need to be registered by the client. A big advantage is relative to ActiveX. 2. Highly higher security than ActiveX. Running below .NET Common Language Runtime 3. Easy to write. I like C # and Visual Studio .NET. 4. There is a very powerful print control. Use the .NET Framework class library. 5. Supports XML technology directly. 6. He is high in IE compatibility. The same is Microsoft products. In addition, it is important to note that the default security level in .NET Framework SP1 and SP2 cannot run the controlled component directly, but in the .NET Framework 1.1 beta, it can be running directly. Server-side You can use an existing server system and database, which does not require newly adding any new hardware devices and new .NET server managers, they are often important guys who take high salary. :) The server's workflow is: 1. Accept the client's standard XML template query. 2. The database data format is required to convert the database data format into a standard XML data format according to the query requirements. 3. Send XML data through the 80 port.
Feasibility Analysis Since most of the database supports data query and conversion in XML format, such as SQL Server 2000, Oracle 9i, IBM DB2, etc. Large-type relationships. Just use simple settings to perform XML data conversion work. If the database cannot support direct XML data conversion, you can use some server-side scripts to convert work, such as JSP, ASP, PHP, and more. The client does not require any special settings, just install a .NET Framework distribution package with a size of 21m, and then open the web page to work. There is also no operating system restriction, it can support it from Windows 98 to Windows XP. Substancy and safety scalability Since the XML standard data format is used as intermediate data exchange, this solution has very good scalability, for example, the client's .NET control can be written in Java Applet, ActivX or VB, VC, etc. The client application is replaced directly. The server can also be arbitrarily selected by IIS or APACHE and other web servers. A database can also be used in any database. Includes SQL Server, Oracle or Access, etc.. This above has already talked, because the length of the article does not make the T-shirt that is given to me, and then emphasizes it just to deepen the readers' cross-platform understanding of XML. :) Safety Since the use of a normal web server transmitting data, it can directly adopt SSL security sockets and other already mature web encryption techniques. At the same time, XML can be encrypted on the data algorithm, and decrypt the client to ensure the security of the transmission. Since the 80-port is used, it is not necessary to add another new dedicated port, which reduces the possibility of security vulnerabilities, and it can easily pass the network firewall and other protective equipment for both parties. The plan design is defined in order to control the format of printing, we define the following format tags, where to refer to HTML naming approach, so it is basically familiar with HTML to see the specific meaning of the label. If you think that these tags have not strong enough, you can also define some more and more precise format tags. Label application example:
true landscape> A4 paperkind> 210 paperwidth> 297 paperHeight> 0 PageLeft> 0 PAgeright> 0 pagetop> 0 pagebottom> pagesetting> latest transaction contract information text> Tabulation time: "Y =" 100 "fontname =" "" Y = "100" FontName = " Song "FontSize =" 12 "fontcolor =" black "b =" true "i =" false "u =" true "> unit: element text>
contract number td>
Product Name td> < Td width = "50" align = "center" fontname = "Song" fontsize = "12" fontcolor = "black" b = "true" i = "false" u = "false" bgcolor = "white"> transaction volume < / TD>
Note: a) If the server script dynamically generates an XML document, the sending content type should be set to Text / XML (normal HTML page is TEXT / HTML), and the character encoding should be UTF-8, otherwise the encoding error problem will occur. B) The file should be generated in strict accordance with the format specified in XML, otherwise the XML parser will not be parsed. 2. The client can use any application to read the XML file generated by the server side. If you use a desktop application software development tool for VB, Delphi, you can use the MSXML COM parser. It is recommended to use .NET, the interior has integrated XML parser, which can be used directly by using the .NET class library. You can make both desktop applications, via remote calls; can also be embedded in the IE browser, running directly on the web page. Effects Example Diagram Print Preview Preview: 1. If you use .NET, the client must install .NET Framework1.0 running environment, download address is: http://download/.netframesdk/redist/1.0 /W98NT42kmexp/en-us/dotnetredist.exe 2. If you are embedded in the web page, then this program needs to be compiled into a control form (a file extension DLL), then insert the following tag in the web: