Html2pdf.js 结果是 vue 中的空白 PDF

问题描述

我有一个 vue 组件,我想将此组件转换为 PDF 文件。我使用了 html2pdf.js 包,但结果是一个包含 3 页的空白 PDF。我怎样才能让它工作?

<template>
    <div>

      <div ref="document">

        <h2> hello</h2>

      </div>
 <button class="btn btn-success text-center" @click="createPDF">  دریافت فایل pdf</button>

    </div>


</template>

<script>


import html2pdf from 'html2pdf.js'

export default {

    data(){
      return{
      }
    },props : ['result'],watch: {
    },methods: {
        createPDF () {
    html2pdf(this.$refs.document,{
                    margin: 1,filename: 'document.pdf',image: { type: 'jpeg',quality: 0.98 },html2canvas: { dpi: 192,letterRendering: true,scale: 1,useCORS: true},jsPDF: {   unit: 'in',format: 'a4',orientation: 'landscape' }
                })
   }
    }
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)