简体   繁体   English

Vue html2pdf,html元素错误生成到pdf文件

[英]Vue html2pdf, html element is wrong generated to pdf file

I write app in Vue and I want to use vue-html2pdf to generate some pdf file from an html element but my pdf is cut.我在 Vue 中编写应用程序,我想使用 vue-html2pdf 从 html 元素生成一些 pdf 文件,但我的 pdf 被剪切了。 Here is screen of the html element: HTML element这是 html 元素的屏幕: HTML 元素

And here is the pdf file generated: PDF file这是生成的 pdf 文件: PDF 文件

The code of element I want to generate as pdf file.我要生成的元素代码为 pdf 文件。

<vue-html2pdf
      :show-layout="false"
      :float-layout="true"
      :enable-download="true"
      :preview-modal="true"
      :paginate-elements-by-height="1000"
      filename="hee hee"
      :pdf-quality="2"
      :manual-pagination="false"
      pdf-format="a4"
      pdf-orientation="portrait"
      pdf-content-width="800px"
      ref="html2Pdf"
  >
      <section slot="pdf-content" >
        <section class="pdf-content">
          <WarscrollComponent 
            v-for="(miniscroll, index) in getScrollsToPrint" 
            :key="index" 
            :miniscroll="miniscroll"
            component="printSheet"
          />
        </section>
      </section>
    </vue-html2pdf>

Do you have any ideas what I'm doing wrong?你知道我做错了什么吗?

I know this isn't the perfect answer.我知道这不是完美的答案。 But, at least it did work for me and have to live with that as there is no other proper solution.但是,至少它确实对我有用并且必须忍受它,因为没有其他合适的解决方案。

I have to add margin-top: -1123px on the top section of the content of the PDF, which removed space from the top for me.我必须在 PDF 内容的顶部添加margin-top: -1123px ,这为我移除了顶部的空间。

Your combination should be different, but I am sure there will be one combination that works for you as well.您的组合应该有所不同,但我相信会有一种组合也适合您。

Please add a comment if someone has a standardised solution for it.如果有人对此有标准化的解决方案,请添加评论。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM