简体   繁体   English

转换为 PDF

[英]Converting to PDF

I don't know whether this question has been asked/answered.我不知道这个问题是否被问过/回答过。 I am making an online form website thing for a school project.我正在为一个学校项目制作一个在线表单网站。 I have to try and have a button that converts the filled out form to PDF.我必须尝试使用一个按钮,将填写的表格转换为 PDF。 Do I need to download some software to do this or can it be done with code.我需要下载一些软件来做到这一点还是可以用代码来完成。 From what I have seen from searching it up it seems like some high level programming.从我通过搜索看到的内容来看,这似乎是一些高级编程。 If it can be done with code, what is the code?如果可以用代码完成,代码是什么?

Print whole page打印整页

Try adding a button that calls window.print()尝试添加一个调用 window.print() 的按钮

<input type="button" value="Print this page" onClick="window.print()">
Print a specific portion/container in a page

<div id="print-content">
 <form>

  <input type="button" onclick="printDiv('print-content')" value="print a div!"/>
</form>
</div>

then in HTML file add this script code然后在 HTML 文件中添加此脚本代码

<script type="text/javascript">
    function printDiv(divName) {
        var printContents = document.getElementById(divName).innerHTML;
        w=window.open();
        w.document.write(printContents);
        w.print();
        w.close();
    }

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

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