添加导出PDF按钮

该示例展示了,使用 按钮添加 API 给报表文件添加导出PDF文件的按钮。

<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <title>ActiveReports for JavaScript sample</title> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <link rel="stylesheet" href="https://cdn.materialdesignicons.com/2.8.94/css/materialdesignicons.min.css" /> <script src="/activereportsjs/demos/arjs/dist/ar-js-core.js"></script> <script src="/activereportsjs/demos/arjs/dist/ar-js-viewer.js"></script> <script src="/activereportsjs/demos/arjs/dist/ar-js-pdf.js"></script> <script src="/activereportsjs/demos/arjs/dist/ar-js-html.js"></script> <script src="/activereportsjs/demos/arjs/dist/ar-js-xlsx.js"></script> <script src="/activereportsjs/demos/arjs/dist/ar-js-xlsx.js"></script> <script src="/activereportsjs/demos/arjs-localization/dist/ar-js-locales.js"></script> <script src="$DEMOROOT$/lib/purejs/license.js"></script> <link rel="stylesheet" type="text/css" href="/activereportsjs/demos/arjs/styles/ar-js-ui.css" /> <link rel="stylesheet" type="text/css" href="/activereportsjs/demos/arjs/styles/ar-js-viewer.css" /> <link rel="stylesheet" type="text/css" href="app.css" /> </head> <body onload="load()"> <div class="container"> <div style="width: 100%" id="root"></div> </div> <script> function load() { viewer = new ActiveReports.Viewer("#root", { language: "zh" }); //pdfExportButton using iconCssClass pdfExportButton = { key: "pdfExternalExportButton", iconCssClass: "mdi mdi-file", text: "PDF Export", title: "PDF Export", checked: true, enabled: true, action: function (item) { var settings = { title: "Invoice List", userPassword: "user_Pwd" }; var cancelCallback = function () { return false; }; viewer .export("pdf", settings, { cancel: cancelCallback }) .then((result) => result.download("Exported_PDF")); }, }; //Add ExportPdf button viewer.toolbar.addItem(pdfExportButton); viewer.registerFont("fonts/fontsConfig.json").then(function () { viewer.open("Quotation.rdlx-json"); }); } </script> </body> </html>