Click here to Skip to main content
15,949,741 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
See more:
Hi all,
I am unable to display 'Text Box' in pdf while converting html string to pdf using HTMLWorker(iTextSharp.dll)

Code:

C#
Document pdfDoc = new Document();
pdfDoc.Open();
iTextSharp.text.html.simpleparser.HTMLWorker hw = new
iTextSharp.text.html.simpleparser.HTMLWorker(pdfDoc);
string sttt = "<input type='text' name='firstname' value='Hello/>";
hw.Parse(new StringReader(sttt ));
pdfDoc.Close();
Posted
Updated 22-Sep-13 5:23am
v9
Comments
Sergey Alexandrovich Kryukov 19-Sep-13 1:03am    
Not informative. What does it mean, "I'm unable"? And how it is, "display Text Box"? What it should be? PDF is not HTML...
—SA
[no name] 19-Sep-13 1:10am    
Hello, do u have any solution for this problem?
[no name] 19-Sep-13 1:05am    
Just I need to display text box in my pdf
Thanks7872 19-Sep-13 1:06am    
Use reply button while making comment.
[no name] 19-Sep-13 1:08am    
Ya fine, is there any specific reason behind it?

1 solution

If you want to add a text box to your PDF file, then have a look here:
http://stackoverflow.com/a/13191097/[^]

[EDIT]

I found the reason why it is not working: your HTML code is not well-formed, because the value attribute is not closed: there's an apostrophe missing.
Try this:
C#
string sttt = "<input type='text' name='firstname' value='Hello'/>";
 
Share this answer
 
v4
Comments
[no name] 23-Sep-13 0:44am    
That's fine ProgramFOX, and thank you first of all,

Here the problem is, I want to add text box through html code. Because I am converting html code to pdf using HTMLParser.

Here I am able to parse total my html code into pdf except this text box so.....
Thomas Daniels 23-Sep-13 12:32pm    
I'm sorry, but I'm afraid there's a way to create the text box from the input tag, because I find nothing about it in Google. I only found the way as described in the link. Again, I'm sorry.
What you can try: use a HTML parser such as the HtmlAgilityPack, and parse some input tags from the HTML, and make sure that they're added as described in the link.
[no name] 25-Sep-13 0:30am    
Hi ProgramFOX,
Actually I used HTMLWorker which belongs to iTextSharp.dll.
It's open source dll to convert any page into pdf format. Using this dll I am unable to add textbox to pdf.(Me to also searched lot of sites in Google to solve this issue.)
[no name] 25-Sep-13 4:18am    
Hello Program FOX,
I think it's not correct ask you in this way
Please go through below link

http://www.codeproject.com/Questions/658544/Gmail-view-image-link-is-asking-credentials-to-see
Thomas Daniels 25-Sep-13 11:44am    
I don't really understand the question.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900