By mikel
Address: http://www.mikel.cn
Recently, you need to print the bill of lading. Previously, you used the report machine control of delphi to make reports. It is very powerful. You can design reports and separate report files from programs, this time I needed to print on paper, so I thought of using activex components to develop printing components.
In this way, this tutorial is divided into two parts: one is Delphi activex component development, and the other is about how ASP. net mvc calls activex components for printing.
1. Develop Activex Components in Delphi
Print Method
Register Activex Components
Compile and generate Activex Components
A printing ActiveX component has been created. How to Use the ReportMachine report component? I will write a detailed tutorial later.
The following describes how. Net calls Activex components.
2. ASP. net mvc calls Activex component Printing
1. add reference to Activex Components
2. Select the report Activex component of Delphi.
3. Reference The report file to the Content folder.
4. in About. aspx. in the onload time of cs, the print method declared by Activex component of Delphi is called for printing. Therefore, the report must be assigned to the server. rmf is the absolute address of the report file to the print method, so that the report component can load the report file correctly. The specific code is as follows:
View Source Code
Print help
02 |
using System.Collections.Generic; |
06 |
using ActiveFormProj1; |
08 |
namespace TangCMS.Views.Home |
10 |
public partial class About : ViewPage |
12 |
protected override void OnLoad(EventArgs e) |
14 |
// Declare the ActivexForm object of the Activex component |
15 |
ActiveFormX report = new ActiveFormX(); |
16 |
// Call the print method declared by Activex Components |
17 |
string file = Server.MapPath( "~/content/report.rmf" ); |
5. Release site. Click the "About Us" link to bring up the report preview and print window. The final result is as follows: