[Original] ASP. net mvc calls the Web report printing activex component developed by Delphi

Source: Internet
Author: User

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

  • Create an ActiveXform project ,:

    Create activexform

  • To set the project release option, you must note that due to the Delphi7 bug, you can set the Web Deploy option only after the project is created for the first time. You cannot set the option when you close the project and open it again. Please note this!

    Set activexform Project

  • Drag the RMRport control to the form and drag the RMUserDataset component to the form. This is suitable for printing the data transmitted to the RMReport,

    Add the RMReport print component to the form

  • Set the DataSet attribute of RMReport1 to RMUserDataset1.
  • Declare external methods and attributes: select View> Type Library

 

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

01 using System;
02 using System.Collections.Generic;
03 using System.Linq;
04 using System.Web;
05 using System.Web.Mvc;
06 using ActiveFormProj1;
07  
08 namespace TangCMS.Views.Home
09 {
10  public partial class About : ViewPage
11  {
12  protected override void OnLoad(EventArgs e)
13  {
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");
18  report.Print(file);
19  
20  }
21  }
22 }

5. Release site. Click the "About Us" link to bring up the report preview and print window. The final result is as follows:

 

 

 

Related Article

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.