无法使用 vue-html2pdf 将 HTML 代码转换为 PDF [英] Cannnot convert HTML code to PDF with vue-html2pdf

查看:67
本文介绍了无法使用 vue-html2pdf 将 HTML 代码转换为 PDF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 vuejs 中有一个项目,我必须使用 vue-html2pdf.

I have a project in vuejs and I have to use vue-html2pdf.

当我在 in 标签中写入文本时:

something
,我的 PDF 就生成了.但是当我在标签中写入:

something

When I write text the in tag: <section>something</section>, my PDF is generated. But when I write in tag: <section><p>something</p></section>, my browser is crashes.

这是我在 vuejs 中的代码:

Here my code in vuejs:

<vue-html2pdf
    :show-layout="false"
    :preview-modal="true"
    :paginate-elements-by-height="10"
    :filename="test"
    :pdf-quality="2"
    :pdf-format="size"
    :ref="ref"
>
    <section slot="pdf-content">
        <section class="pdf-item">
            <img :src=url>
        </section>
    </section>
</vue-html2pdf>

还有我下载PDF的功能:

And my function to download PDF:

function generateReport() {
  this.$refs.html2Pdf.generatePdf();
}

推荐答案

vue-html2pdf npm 模块无法正常工作.而不是您可以尝试 html2pdf 模块在 vuejs 中将 html 转换为 pdf.

vue-html2pdf npm module does not work properly. Rather than you can try html2pdf module for convert html to pdf in vuejs.

包链接:https://www.npmjs.com/package/html2pdf.js/v/0.9.1

Codesandbox 示例:https://codesandbox.io/s/xlnzq7y28q

Codesandbox Example: https://codesandbox.io/s/xlnzq7y28q

希望,您的问题将得到解决.谢谢.

Hope that, your problem will be solved. Thanks.

这篇关于无法使用 vue-html2pdf 将 HTML 代码转换为 PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆