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

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

ActiveReportsJS默认可以导出PDF、Excel、Html。但是在导出PDF的时候需要进行字体文件的配置,如果没有进行字体配置,那么导出PDF就会出现乱码

下面就来进行字体配置的具体讲解


1、首先新建一个项目,项目名称叫做 "arjsfont"

2、打开public文件,新建一个fonts文件,进行字体的配置

配置文件(这里我默认设置的字体是微软雅黑)

{
    "path""",
    "descriptors": [
        {
            "name""微软雅黑",
            "locals": [
                "微软雅黑",
                "MicrosoftYaHei"
            ],
            "source""fonts/SimHei.ttf" 
        },
        {
            "name""微软雅黑 Light"         
        },
        {
            "name""等线"
        },
        {
            "name""等线 Light"
             
        },
        {
            "name""宋体",
            "source""fonts/SimHei.ttf"
 
 
        },
        {
            "name""仿宋"
        },
        {
            "name""新宋体"
        },
        {
            "name""幼圆"
        },
        {
            "name""楷体"
        },
        {
            "name""隶书"
        },
        {
            "name""黑体",
            "source""fonts/SimHei.ttf"
        },
        {
            "name""Arial"
        },
        {
            "name""Arial Black"
        },
        {
            "name""Comic Sans MS"
        },
        {
            "name""Courier New"
        },
        {
            "name""Geneva"
        },
        {
            "name""Georgia"
        },
        {
            "name""Helvetica"
        },
        {
            "name""Impact"
        },
        {
            "name""Lucida Console"
        },
        {
            "name""Meiryo"
        },
        {
            "name""Meiryo UI"
        },
        {
            "name""MingLiU"
        },
        {
            "name""MingLiU-ExtB"
        },
        {
            "name""MS Gothic"
        },
        {
            "name""MS Mincho"
        },
        {
            "name""MS PGothic"
        },
        {
            "name""MS PMincho"
        },
        {
            "name""MS Song"
        },
        {
            "name""MS UI Gothic"
        },
        {
            "name""NSimSun"
        },
        {
            "name""Osaka"
        },
        {
            "name""PMingLiU"
        },
        {
            "name""PMingLiU-ExtB"
        },
        {
            "name""SimSun"
        },
        {
            "name""SimSun-ExtB"
        },
        {
            "name""Song"
        },
        {
            "name""Tahoma"
        },
        {
            "name""Times New Roman"
        },
        {
            "name""Trebuchet MS"
        },
        {
            "name""Verdana"
        },
        {
            "name""Yu Gothic"
        }
    ]
}

3、打开项目中的 app.vue文件,导入该方法:

import { FontStore } from "@grapecity/activereports/core";

具体代码

<template>
  <div id="viewer-host">
    <JSViewer v-bind:availableExports="['pdf', 'xlsx', 'html']" v-bind:report="{ Uri: 'zuantoushiyong.rdlx-json' }"></JSViewer>
  </div>
</template>
<script>
    import { Viewer } from "@grapecity/activereports-vue";
    import "@grapecity/activereports/styles/ar-js-ui.css";
    import "@grapecity/activereports/styles/ar-js-ui.css";
    import "@grapecity/activereports/styles/ar-js-viewer.css";
    import "@grapecity/activereports"
    import { FontStore } from "@grapecity/activereports/core";
export default {
  name: "App",
  components: {
    JSViewer: Viewer,
  }
  }
  FontStore.registerFonts("/fonts/fontsConfig.json");//引入字体配置json文件
</script>
<style>
#viewer-host {
  width: 100%;
  height: 100vh;
}
</style>

4、预览结果

5、导出PDF样式

6、Demo实例下载

  • No labels