如何使用Wkhtmltopdf转换器充满文本框? [英] How to use Wkhtmltopdf converter with filled text boxes?

查看:550
本文介绍了如何使用Wkhtmltopdf转换器充满文本框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要的是一个点击按钮时几个aspx页面转换为PDF。出现这种情况后,许多文本框填写等控件选择等Wkhtmltopdf呈现PDF非常漂亮,但一切都是空白。基本上,在创建PDF时,它是在该形式是在上载的状态。我想要的PDF是在表单中当按钮pressed的状态。我需要思想的方法来解决这个问题,为了节省填充文本框的PDF文件。

I need to convert several aspx pages to PDF when a button is clicked. This happens after many text boxes are filled and other controls are selected, etc. Wkhtmltopdf renders the pdf very nicely but everything is blank. Basically, when the PDF is created it is in the state that the form was in on load. I want the PDF to be in the state that the form is in when the button is pressed. I need ideas for a way to work around this issue in order to save the pdf with the text boxes filled.

推荐答案

wkhtmltopdf 使得它看到一个HTML页面,浏览器而不是如何显示。当您填写表单,字段中的值不是底层的HTML结构的一部分(虽然他们是DOM的一部分)。作为变通,你可以做到以下几点:

wkhtmltopdf renders an HTML page it "sees", not how the browser displays it. When you fill out the form, the values in the fields are not part of the underlying HTML structure (though they are part of the DOM). As a work-around, you can do the following:


  1. 捕获并保存所有的表单参数值的某处时,提交表单(会议,文件,数据库等)。

  1. Capture and save all of the form parameters' values somewhere (session, file, database, etc) when the form is submitted.

使用相同的code作为表单页面生成一个新的HTML页面。

Generate a new HTML page using the same code as the form page.

在你有直接保存到HTML code表格填写值。换句话说,指定与您拍摄的输入表单上的属性。

Fill in the form values you had saved directly into the HTML code. In other words, specify the value attributes on the form with the inputs you captured.

例如,如果您有 CUSTOMER_NAME 称为一个文本字段,用户提交的李四,硬code中的值写入标签:

For example, if you have a text field called customer_name and the user submitted John Doe, hard-code the value into the tag:

<input type="text" name="customer_name" value="John Doe">


现在 wkhtmltopdf 可以渲染填写值的形式。

Now wkhtmltopdf can render the form with the values filled out.

这篇关于如何使用Wkhtmltopdf转换器充满文本框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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