Tuto WEBDEV 25
212 Part 5: Let’s continue the development Displaying the printed report from a button As already seen at the beginning of this lesson, the site being run on a server, the document will be printed on a printer connected to the server (and therefore inaccessible to the user). Therefore, the report will be printed in PDF on the server and the generated PDF document will be downloaded or displayed on the Web user’s computer. Then, the user will be able to print the document on their printer. In our site, "RPT_Invoice" will be printed from a Button control in the page used to find an order. This Button control will print the invoice for the selected order. Remark: To complete this part of the tutorial, the page "PAGE_Multicriteria_Search" must have been created in Lesson 5.1. Multicriteria search. Implementing the print To print the "RPT_Invoice" report: 1. Locate the "PAGE_Multicriteria_Search" page: click "PAGE_Multicriteria_Search" in the documents bar. 2. On the "Creation" pane, in the "Usual controls" group, click "Button". 3. Click on the right of the Table control to create the Button control. 4. Select the control and press Enter. The caption becomes editable. 5. Replace "Button" by "Print" and validate. 6. Open the code of this button (F2) and write the following code in the "Click (server)" event: iDestination(iGenericPDF) iInitReportQuery(RPT_Invoice, ... TABLE_QRY_FindOrders.COL_OrderID[TABLE_QRY_FindOrders]) iPrintReport(RPT_Invoice) FileDisplay(iLastFile(), "application/pdf") Let’s study this code: • iDestination is used to define the print format (PDF format in this case). • The "RPT_Invoice" report being based on a query with parameters, the parameter must be passed to the query before running the report. This operation is performed by iInitReportQuery . In our case, the parameter corresponds to the number of the current order, displayed in the Table control.
Made with FlippingBook
RkJQdWJsaXNoZXIy NDQ0OA==