工具栏更新

该示例展示了,使用 导出 API 进行工具栏按钮位置调整。

<!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" }); var svgExcelLogo = atob( "PHN2ZyB4bWxuczpkYz0iaHR0cDovL3B1cmwub3JnL2RjL2VsZW1lbnRzLzEuMS8iIHhtbG5zOmNjPSJodHRwOi8vY3JlYXRpdmVjb21tb25zLm9yZy9ucyMiIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyIgeG1sbnM6c3ZnPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczpzb2RpcG9kaT0iaHR0cDovL3NvZGlwb2RpLnNvdX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aDEwdjYgYzAsMS4xLDAuOSwyLDIsMmg1djJINmMtMS43LDAtMywxLjMtMywzdjdjMCwxLjcsMS4zLDMsMywzSDE5TDE5LDI2TDE5LDI2eiBNMTMsM3Y2YzAsMC42LDAuNSwxLDEsMWg1TDEzLDNMMTMsM3ogTTYsMTQgICAgYy0xLjEsMC0yLDAuOS0yLDJ2N2MwLDEuMSwwLjksMiwyLDJoMjNjMS4xLDAsMi0wLjksMi0ydi03YzAtMS4xLTAuOS0yLTItMkg2TDYsMTR6IE0yOSwyMnYxaC01di03aDF2NkgyOUwyOSwyMnogTTE0LDE3djZoMXYtNiBoMnYtMWgtNXYxSDE0TDE0LDE3eiBNMTAsMTl2LTNoMXY3aC0xdi0zSDd2M0g2di03aDF2M0gxMEwxMCwxOXogTTIwLjUsMTlMMTksMTZoLTAuNUgxOHY3aDF2LTVsMSwyaDAuNUgyMWwxLTJ2NWgxdi03aC0wLjVIMjIgTDIwLjUsMTlMMjAuNSwxOXoiLz48L2c+PC9nPjwvc3ZnPg==" ); //pdfExportButton using iconCssClass //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")); }, }; //xlsxExportButton using svg icon xlsxExportButton = { key: "xlsxExternalExportButton", icon: { type: "svg", content: svgExcelLogo }, title: "Excel Export", checked: true, enabled: true, action: function (item) { var settings = { creator: "Jack", password: "Pwd" }; var cancelCallback = function () { return false; }; viewer .export("xlsx", settings, { cancel: cancelCallback }) .then((result) => result.download("Exported_XLSX")); }, }; //htmlExportButton using svg icon htmlExportButton = { key: "htmlExternalExportButton", icon: { type: "svg", content: svgHTMLLogo }, title: "HTML Export", checked: true, enabled: true, action: function (item) { var settings = { autoPrint: "true" }; var cancelCallback = function () { return false; }; viewer .export("html", settings, { cancel: cancelCallback }) .then((result) => result.download("Exported_HTML")); }, }; viewer.toolbar.addItem(pdfExportButton); viewer.toolbar.addItem(xlsxExportButton); viewer.toolbar.addItem(htmlExportButton); //调整工具栏的按钮的显示顺序和显示的按钮,可以根据自己的需求进行工具栏的调整。 viewer.toolbar.updateLayout({ default: [ "xlsxExternalExportButton", "$navigation", "$history", "$fullscreen", "$split", "$print", "$refresh", "$galleymode", "$mousemode", "$split", "$continuousmode", "$singlepagemode", "$zoom", "htmlExternalExportButton", "pdfExternalExportButton", "$split", ], }); viewer.registerFont("fonts/fontsConfig.json").then(function () { viewer.open("Quotation.rdlx-json"); }); } </script> </body> </html>