디자이너 컴포넌트 - 보고서 출력 미리 보기

이 샘플은 Angular, React, Vue 및 순수 JavaScript 응용 프로그램 내에서 ActiveReportsJS Designer 컴포넌트의 보고서 출력을 미리 보는 방법을 보여 줍니다. 디자이너 도구 모음에서 "미리 보기" 버튼을 클릭하면 현재 보고서가 표시된 뷰어가 열립니다. "PDF 미리 보기" 버튼을 클릭하면 보고서를 PDF로 내보내고 브라우저 설정에 따라 보고서가 자동으로 열리거나 다운로드됩니다. "디자이너 열기" 버튼을 클릭하면 디자이너 컴포넌트가 표시됩니다. 자세한 내용은 보고서 미리 보기 페이지를 방문하십시오. 코드를 보려면 아래로 스크롤하십시오.

<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <title>ActiveReportsJS Report Designer Report Preview Sample</title> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <script src="/activereportsjs/demos/arjs/dist/ar-js-core.js"></script> <script src="/activereportsjs/demos/arjs/dist/ar-js-designer.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-tabular-data.js"></script> <script src="/activereportsjs/demos/arjs/dist/ar-js-html.js"></script> <script src="$DEMOROOT$/lib/purejs/license.js"></script> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous" /> <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="/activereportsjs/demos/arjs/styles/ar-js-designer.css" /> <style> #designer-host, #viewer-host { margin: 0 auto; width: 100%; height: 500px; } .hide { display: none; } </style> </head> <body> <div id="designer-toolbar" class="container-fluid"> <div class="row mt-3 mb-3"> <button id="btnPdfPreview" type="button" class="btn btn-outline-primary btn-sm col-sm-2 ml-1" onclick="onPdfPreview()" > PDF Preview </button> <button id="btnDesignerOpen" type="button" class="btn btn-outline-primary btn-sm col-sm-2 ml-1 hide" onclick="onOpenDesigner()" > Open Designer </button> </div> </div> <div id="designer-host"></div> <div id="viewer-host" class="hide"></div> <script> function setVisibility(selector, isVisible) { document.querySelectorAll(selector).forEach(function (element) { isVisible ? element.classList.remove("hide") : element.classList.add("hide"); }); } var designer = null; function onOpenDesigner() { setVisibility("#viewer-host, #btnDesignerOpen", false); setVisibility("#designer-host, #btnPdfPreview", true); } async function onPdfPreview() { const reportInfo = await designer.getReport(); const report = new MESCIUS.ActiveReportsJS.Core.PageReport(); await report.load(reportInfo?.definition); const doc = await report.run(); const result = await MESCIUS.ActiveReportsJS.PdfExport.exportDocument( doc ); result.download("exportedreport"); } MESCIUS.ActiveReportsJS.Core.FontStore.registerFonts( "/activereportsjs/demos/resource/fontsConfig.json" ); designer = new MESCIUS.ActiveReportsJS.ReportDesigner.Designer( "#designer-host" ); designer.setActionHandlers({ onRender: (report) => { setVisibility("#viewer-host, #btnDesignerOpen", true); setVisibility("#designer-host, #btnPdfPreview", false); viewer.open(report.definition); return Promise.resolve(); }, }); designer.setReport({ id: "reports/company-template.rdlx-json" }); var viewer = new MESCIUS.ActiveReportsJS.ReportViewer.Viewer( "#viewer-host" ); </script> </body> </html>