Fastreport Studio 3: Print and preview

Source: Internet
Author: User
A software for printing certificates is required for the project: The printed format must be exactly the same as the paper to be printed (not A3 or A4) and cannot be misplaced or reversed.. Fixed the position of the printed text to be adjusted. The position of the printed paper varies, and the specified paper needs to be adjusted.
Here I chose the fastreport control. Let's briefly describe the features of the fastreport control:
Fastreport studio is a powerful, streamlined, and flexible environment for your applications to automatically and quickly generate reports. Fastreport provides all the tools for developing reports. It includes the report engine, designer, Form Design preview dialog box, and four powerful explanatory programs: Basic (VB) style, C ++ style, JS style and Pascal style.
The patch includes the fastreport COM Service, standard design, and source code demo programs for Visual C ++, Microsoft Visual C #. net, Microsoft Visual Basic. net, Microsoft Asp.net, and Microsoft FoxPro. I used its preview and printing functions, as well as export functions (PDF, RTF, Excel, XML, HTML, JPEG, BMP, Tiff, text, CSV, and other formats)
Fastreport provides the ADO engine to directly access data in the designer. However, in my actual application, the data to be printed varies depending on the selection. Therefore, I did not specify the adoquery (query) of the ADO engine in the designer ). I use. Net code to set it from the outside.

Pseudocode
// Print and preview Methods
Private void print (bool ispreview)
{
Tfrxreportclass mainreport = new tfrxreportclass ();

// Create ADO database object
Tfrxadodatabaseclass ado_database = new tfrxadodatabaseclass ();
Ado_database.connectionstring = "connect to Database ";
Ado_database.loginprompt = false;

// Create ADO query object
Tfrxadoqueryclass adoquery = new tfrxadoqueryclass ();
Adoquery. Database = ado_database;
Adoquery. Name = "ado_query"; // The name must be the same as the data source bound to the designer.
Adoquery. query = "SQL statement ";

Try
{
Mainreport. loadreportfromfile (@ "fr3 \ report. fr3"); // load the topic Template
Mainreport. selectdataset (true, adoquery );

// Display the preview dialog box
If (ispreview)
{
Mainreport. previewoptions. allowedit = false;
Mainreport. showreport ();
}
Else
{
Mainreport. preparereport (false );
Mainreport. printreport ();
}
}
Catch (exception ex)
{
Loggermanager. loggtotxt (Ex );
MessageBox. Show ("An error occurred while printing the template file! "," Error ", messageboxbuttons. OK, messageboxicon. Error );
}
}

The above is one of the main methods I use in the printed software.
OK. The print and preview methods in the fastreport control are used. This is even a reading note for future search.

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.