简体   繁体   中英

Convert ASPX to PDF format

I have several ASPX web forms which contain all kinds of text boxes, combo boxes, radio button lists, and a lot of other fancy telerik controls. After a form is filled out it needs to be converted to PDF and then printed. I tried wkhtmltopdf but the text boxes in the output were all empty. I have also tried iTextSharp but can't seem to get rid of the InvalidCastException from HTMLWorker.Parse(). I tried the Essential Objects trial version of EO.PDF which worked perfectly except that it would cost lots of money to purchase and probably isn't worth it. I seem to find a lot of examples that are only basic html to pdf converters and won't work with controls. It also seems like many use GridView or similar for iTextSharp, but I don't know much about gridView or if it would help me here.

I need a ideas to try or possibly a solution to my problems with iTextSharp or wkhtmltopdf. Any help would be appreciated. Thanks in advance!

The fields are coming out blank because the filled-out information is not part of the HTML structure of the code. The browser shows it, but wkhtmltopdf cannot see it.

Easy work-around:

  1. On form submission, save the submitted values somewhere.

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

  3. Pre-fill the form's HTML with the values you saved in Step 1. Eg specify the value attributes on the form with the submitted data:

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

wkhtmltopdf can now render the form with the values hard-coded in the HTML.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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