Page tree
Skip to end of metadata
Go to start of metadata

ActiveReportsJS自带有打印的能力,并且提供打印的接口。即在不预览报表情况下,可以直接打印,代码示例

1、ActiveReportsJS的打印API实现代码

import { Core } from "@grapecity/activereports";
const report = new Core.PageReport();
await report.load("/reports/text-only.rdlx-json");
const doc = await report.run();
doc.print();

2、App.vue中具体实现代码

<template>
<div>
   <button @click="expPrint" style="wedth:100Px;height:30Px;margin-bottom:5px;">打印</button>   
     <JSViewer id="viewer" ref="reportViewer" style="height:800Px"></JSViewer>
</div>
</template>
<script>
  import { Viewer } from "@grapecity/activereports-vue";
  import "@grapecity/activereports/styles/ar-js-ui.css";
  import "@grapecity/activereports/styles/ar-js-viewer.css";
  import "@grapecity/activereports"
  export default {
    name: "App",
    components: {
      JSViewer: Viewer,
    },
    mounted:async function(){    
     this.$refs.reportViewer.Viewer().open('MonthSurvey.rdlx-json');
    },
    methods:{
      expPrint(){              
          this.$refs.reportViewer.Viewer().print();     
      }
    }   
  };
</script>
<style>
  #viewer{
    width: 100%;
    height: 100vh;
  }
</style>

3、预览展示结果

4、demo实例下载

vueprint.rar


  • No labels