简体   繁体   English

使用php代码生成HTML表单数据的PDF,无需其他工具

[英]generate PDF of html form data using php code no other tool

I need some help. 我需要协助。 I'm searching for almost 2 days but I can't find the perfect answer. 我正在搜索将近2天,但找不到最佳答案。 so I have a HTML form when I submit the click button it saves data in the database now I need to generate a pdf of my HTML form when data is submitted and automatically mail it to my email address. 因此,当我提交单击按钮时,我有一个HTML表单,它将数据保存在数据库中。现在,我需要在提交数据时生成HTML表单的pdf,并将其自动邮寄到我的电子邮件地址。 I need to generate pdf file without using any tool or any other demo like FPDF or anything like that. 我需要不使用任何工具或任何其他演示(例如FPDF或类似工具)来生成pdf文件。

I want to generate pdf using PHP code. 我想使用PHP代码生成pdf。 can it be done? 能做到吗 need your help. 需要你的帮助。

thankyou!!!' 谢谢!!!'

<form action="dbconnection.php"  method="post" name="2nd-form" id="form-survey" >   

If it's just saving the code why don't you just save it as a .txt file, attach that, and save yourself all the hassle. 如果只是保存代码,为什么不将其另存为.txt文件,将其附加并保存所有麻烦。 PDF creation is possible but extremely over complicated for simple task without the use of a library of some kind. 无需使用某种类型的库,就可以创建PDF,但是对于简单的任务而言,创建PDF的过程极其复杂。 Writing to txt file is super simple and much easier to maintain that a ton of PHP code. 写入txt文件非常简单,而且很容易维护大量的PHP代码。 If you do end up using a library look into mpdf. 如果确实要使用库,请查看mpdf。 Is much better than fpdf. 比fpdf好得多。 It has better documentation too. 它也有更好的文档。

No you can't create pdf without any library. 不,没有任何库都无法创建pdf。 another good way or my suggestion is you can create a html body using the form content . 另一个好方法或我的建议是,您可以使用表单内容创建html正文 Then add this as html-content in your mail . 然后将其作为html-content添加到您的mail中。

I think this is the easy way to avoid time consuming to create PDF and attach it to mail and send it all. 我认为这是避免浪费时间创建PDF并将其附加到邮件并发送所有内容的简便方法。

Try to use this way or if you want the pdf for some purpose so you should use some library to create it. 尝试使用这种方式,或者如果您出于某些目的想要pdf ,则应使用一些来创建它。

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

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