Click here to Skip to main content
15,169,823 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I need a PDF converter for a C# console application, which takes HTML as input. Please suggest a converter you have used and if you know of any problems with it.
Updated 26-Apr-13 12:20pm
Sergey Alexandrovich Kryukov 26-Apr-13 15:38pm
What's going on? I just answered. Are you the students of the same school getting identical assignments, or what?! And now my answer was removed... It's a shame.
TnTinMn 26-Apr-13 17:05pm
At best students. At worst all bidders for the same rent-a-coder project. :(
Sergey Alexandrovich Kryukov 26-Apr-13 17:22pm
Bidders? Wow. I can imagine the morons who would be ready to pay them! :-)
TnTinMn 26-Apr-13 17:40pm
It's just something that I noticed once after looking over a few of the those sites, that various forums suddenly get a lot of questions on how to code the required tasks. Maybe its a coincidence, but whenever I see a lot of posts on a topic that seems beyond a school topic, I take a look and often someone had posted a job with that requirement.

I seen something similarly fishy here a while ago, where it started off that the poster wrote the program for a friend and it changed to client at the end of the post.
Sergey Alexandrovich Kryukov 26-Apr-13 18:03pm
From time to time, this forum gets 2-5 identical questions from different people during short period of time 1-3 days...
[no name] 26-Apr-13 15:41pm
This is not a question or a description of a problem. We do not write code to order here either.
Jasmine2501 26-Apr-13 17:17pm
There are some answers for this here:

And yes, this question is a little more complicated than I thought and there isn't a "quick answer" for it. GUYS - please don't give her crap, I asked her to post here because I don't have time for a phone call. I wanted this in the discussion area though.
Sergey Alexandrovich Kryukov 26-Apr-13 17:24pm
I answered in sufficient detail. Would you need more? Then it just needs a brain, which cannot be created in a forum. :-)
Jasmine2501 26-Apr-13 18:18pm
Yeah I know, your answer is very good. I'm not the submitter of this question, she's a friend of mine. She doesn't understand how this site works, look at "solution 2" - I should have been more clear and asked her to post this in the discussion area.
Sergey Alexandrovich Kryukov 26-Apr-13 18:21pm
Too bad deletion of posts does not work at this time, hopefully, temporarily. This post should be removed.
Thank you,
Whiressawd 21-Aug-15 5:01am
Unfortunately there is no build in solution to this, you can use some HTML parser like HtmlAgilityPack, Majestic12 or AngleSharp (I haven't tested this one jet but it does seem efficient) together with some library for creating PDF files in C# (for example iTextSharp, PdfSharp, etc.). This would require that you iterate through the HTML content and draw the corresponding graphics on PDF document.
Or alternatively you can find some straightforward solution for HTML to PDF conversion done in C#.

1 solution

To get your input, you may or may not need to parse HTML (maybe, you generate HTML from data, then, instead of parsing, you would need to generate both HTML and PDF). Ideally, you HTML should be well-formed as XML, then you could parse it using one of .NET XML parsers. Not all Web pages are like that, unfortunately, so you may need HTML parser which does not require well-formed XML compliance. Try this one:[^].

To work with PDF, use iText, or its .NET port, iTextSharp:[^],[^],[^].

In included the reference to Java iText site as well, because most documentation is there. If you understand C#, it would not be difficult to understand Java-bases API documentation.


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