how to convert html file (with tables) to pdf file using iTextSharp.

hello,
i searched a lot and also look at iTextsharp tutorials but didn't find any solutions.
i have a html file which contains a table. and i try to convert it into pdf using iTextSharp but it doesn't work.
here is my code:


string inputFile =@"C:\Try.htm";
string outputfile =@"C:\try.pdf";
            try
            {
                // step 1: creation of a document-object
                Document document = new Document(PageSize.A4, 80, 50, 30, 65);

                // step 2:
                // we create a writer that listens to the document
                // and directs a XML-stream to a file
                PdfWriter.GetInstance(document, new FileStream(outputfile, FileMode.Create));


                // step 3: we parse the document
                HtmlParser.Parse(document, inputFile);
            }
            catch (Exception ex)
            {
                throw ex;
            }

 

any help would be greatly appreciated.  


Sudhir Thanki
Software Engineer
Microsoft Certified Technical Specialist.
0
softsan
5/9/2008 8:09:22 AM
asp.net.security 27051 articles. 1 followers. Follow

2 Replies
1775 Views

Similar Articles

[PageSpeed] 27

iTextSharp is not document converter - it is document builder that has support for some different formats. If you want to caonvert HTML file to PDF you should use HTML DOM API or in the case of XHTML XML+XPATH to extract table and its subobjects. Then you have to iterate through extracted objects, create objects that correspond to PDF and add them to PDF document. If you want to make it fast then I suggest you to check out NFop. It takes XML and XSLT, creates FOP format XML and converts it to PDF.
Don't forget to mark solution providing post as "Answered".
It helps others to find correct solutions!

Also visit my ASP.NET blog!
0
DigiMortal
5/9/2008 9:29:44 AM
hey, if your still interested theres a different api called pdf from html which will allow you to create a pdf from a string of html and or css.

Si!
0
blink18jew
6/29/2008 2:05:08 AM
Reply:

Similar Artilces:

How to convert .tiff image file to .pdf file without using any 3rd party tool using C#.net
HI allI have a urgent requirement i want to convert .tiff image to .pdf file Thanks in advance Regards RaviPlease click "mark as answer" if this post helped you. I dont think its possible without doing a lot of code or using third party tools, but if you  are looking for a free tool you can try a combination of http://blog.codebeach.com/2008/02/convert-multipage-tiff-to-pdf-in-net.htmland  http://www.codeproject.com/KB/aspnet/Creating_PDF_documents_in.aspx Thanks and RegardsS.K.Vignesh----------------------Do remember to "Mark as answer" for this pos...

Problem with converting .doc file to .pdf file and also filling it with some details using iTextSharp
Hello Mate,                     I am having a problem in converting a .doc file in to .pdf file using iTextSharp.dll .And also i would like to wirte some details in to the form. the problem is the conversion of .doc to .pdf file is not working and also filling in to the converted .pdf file is also not working.Could you please tell me a solution?   This is my code  in this below method i am passing the full path of an existing .doc file public void Convert_And_Fill(string filepath...

converting html file to pdf file
is there anyway I can convert an html file to a pdf file ?HighOnCodingWanna get high! sure, either you use one time conversion using a program like Adobe Acrobat Professional or want to automate the creation of HTML files into pdf files frequently so you use a component plugged into your ASP.NET app see www.planetpdf.com for more infoThe best glimpse of heaven is on the way into hell ;)yousef.omar@gmail.comhttp://nonstopbiztalk.blogspot.com...

Convert Or Save Pdf file to html file
I want to convert or save pdf file to html programmatically through asp.net 1.1 & C#.Anyone knows solution please let me know coz I do a lot of search but didn't find any kind of solution.  Thanks & regards.   hi, check this link, http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/d835c1c9-0d04-4cb9-8d08-39e68ee911fd/...

COnverting image file into PDF file in C#.NET
hi friends, i have a problem in creating a PDF file from an image file. first of all pls clarify what is the internal concept in converting to PDF file. if nay one knows pls mail me the related code if you find any solution pls mail me at spend5mins@yahoo.com thank u all hari babu...

Convert Gridview Data in to PDf file. or Convert report data in pdf file
 Hi have problem to convert Gridview data into PDF file..let me know is there any solution or open source components..Regards Rambhopal Reddy EPlease remember to click “Mark as Answer” on the post that helps you, and to click “Unmark asAnswer” if a marked post does not actually answer your question. Friend, Check this thread for soultions http://forums.asp.net/t/1164793.aspx and then to http://www.aspnetworld.com/articles/2004011801.aspx   Good luck!     Please Don't forget to click "Mark as Answer" on the post that helped you.This can be benef...

web services used to convert Word files to PDF files
My professor asked me to design a web services which convert Microsoft's word files to PDF files. by use VS.NET and Windows Server 2003. After I installe Adode Acrobat 6.0 Professional, I can find some Acrobat components, Acrobat Distiller, Acrobat Web Capture 1.0 Type Library, etc. Please tell me which one can be used for my project and how to use it. Or please tell me popular free components of third parts. Thanks!...

How to convert a UNICODE html file to BIG5 html file
Hello~I got a HTML file that code is UNICODE. So all traditional chinese characters were encoded such as "中文測試" will be converted to "&#20013;&#25991;&#28204;&#35430;" Please help me that how to convert the "&#20013;&#25991;&#28204;&#35430;"  to "中文測試".I got the HTML file content as below<html><body><ul><li>&#20013;&#25991;&#28204;&#35430;</li><li>good test</li></ul></body></html>I want to new/create a HTML file that content&n...

how to convert dynamicaly loading images to pdf using HTML to PDF Converter for .NET
how to convert dynamicaly loading images to pdf using HTML to PDF Converter for .NET Now am converting using how to convert dynamicaly loading images to pdf using HTML to PDF Converter for .NET  tool. But the dynamicaly loading images are not showing in the pdf .     Are you using 3rd party tool or you are using iTextSharp free utility? If it is 3rd party tool, it's always suggested to ask the company which built the tool. Sreedharhttp://www.w3coder.orgweblog http://weblogs.asp.net/skoganti Hi vishnusekhar, As to convert images/douments ...

How to convert a pdf file to text format using .net
Hi all, I want to convert a PDF format file to a text format file(i.e., Wordpad or Notepad).For this i have to use .Net only. Plz send replies urgently. tnx ramesh...

superreview granted: [Bug 298460] Use xhtml files in content instead of html files in locale : [Attachment 187065] Move both html files
Scott MacGregor <mscott@mozilla.org> has granted Pavel Franc - Pawell (Czilla.cz) <p.franc@gmail.com>'s request for superreview: Bug 298460: Use xhtml files in content instead of html files in locale https://bugzilla.mozilla.org/show_bug.cgi?id=298460 Attachment 187065: Move both html files https://bugzilla.mozilla.org/attachment.cgi?id=187065&action=edit ------- Additional Comments from Scott MacGregor <mscott@mozilla.org> thanks for the patch. This one works much better ...

superreview requested: [Bug 298460] Use xhtml files in content instead of html files in locale : [Attachment 187065] Move both html files
Pavel Franc - Pawell (Czilla.cz) <p.franc@gmail.com> has asked Scott MacGregor <mscott@mozilla.org> for superreview: Bug 298460: Use xhtml files in content instead of html files in locale https://bugzilla.mozilla.org/show_bug.cgi?id=298460 Attachment 187065: Move both html files https://bugzilla.mozilla.org/attachment.cgi?id=187065&action=edit ------- Additional Comments from Pavel Franc - Pawell (Czilla.cz) <p.franc@gmail.com> This is a patch for both credits.html and start.html. After aplaying the patch you need to move mail/locales/en-US/chrome/messenger/s...

Convert file on a path to "Stream" without the use of html "file" control
Hello, Basically I am building a CMS of sorts, I have built in the functionality to generate a thumbnail of an image that get's catalogued, I then take my original file and transfer it to the server along with the thumbnail - which is all working fine... Using the html file control accpets the following: (name - "fileImage") Dim x As Stream = fileImage.PostedFile.InputStream() Which is fine - one file at a time, however I need to build in the functionality to get all the image files from a directory and batch transfer them. basically I will have the path similar to:...

How to convert a PCL file into a PDF file?
How do I convert a PCL file into a PDF file for printing/saving purposes(possibly using Amyuni PDF converter)? Thank you! You would need a 3rd party tool. A search in Google found many results: http://www.google.ca/search?hl=en&q=pcl+to+pdf&btnG=Search&meta= Brad Alex wrote: > How do I convert a PCL file into a PDF file for > printing/saving purposes(possibly using Amyuni PDF > converter)? > > Thank you! ...

Web resources about - how to convert html file (with tables) to pdf file using iTextSharp. - asp.net.security

Facebook Stack Overflow
Stack Exchange log in - careers - chat - meta - about - faq Questions Tags Users Badges Unanswered Ask Question Top Questions active 5 featured ...

Latest Updates
Latest Updates - Free source code and tutorials for Software developers and Architects.; Updated: 15 Feb 2013

PDFs Using iTextSharp
... libraries on the market now that allow you to create PDF documents from your .NET applications. The one I’ve chosen to use is To use iTextSharp, ...

pdfbinder - A simple tool to merge several PDF documents into one - Google Project Hosting
PDFBinder is a simple tool that lets you merge any number of PDF documents into one, without having to resort to slow, user-unfriendly, expensive ...

Introducing PDF and iText
About us - News - Contact iText ® Licenses Support You are here: Home > Support > Book > Chapter 1 Chapters Chapter 1 Chapter 2 Using iText's ...

Mad Scientist Hut
We supply products for the home electronic enthusiast and small labs

Items by Category on MikesDotnetting
Mikesdotnetting - 15 September 2009 22:16 If you are developing a business application using ASP.NET MVC, and need to produce some kind of dashboard-style ...

How to Generate PDFs in Python for Google App Engine
One of my last projects based on google app engine and python involved storing form data in GAE datastore and generating PDF documents that the ...

Sports-Gazer - About Us
Sports-Gazer is an application for ranking and rating sports teams. It also can project scores for upcoming games. Certain parts of this application ...

anatone.net anatone.net - links
globally recognized as the best site on the internet with the name anatone.net

Resources last updated: 1/12/2016 3:20:10 PM