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.