HTML to PDF

C

Class

Hi all,

I am looking for some .NET code which can convert HTML to a PDF.
I have looked the internet bad without any luck so far.

I have found the iText.NET this has alot of sample but couldn't find a
sample for HTML to PDF.
Besides I get the error 'Provider for javax.xml.parsers.SAXParserFactory
cannot be found'
For every example I try.
Also the ABC PDF converter I tried but couldn't figure out how to get this
working also.
So little documentation :-(

Can somebody give me a simple example maybe?
Wihich DLL's I need for this conversion?

Many thanks,

Class
 
B

bruce barker

your options are limited. itext (or the c# version itextsharp) only
handle very simple html. last time i used it, i rewrote the table
support to support nested tables (advantage of open source), but it
still only handled very simple xhtml.

activepdf is the market leader for a 3rd party product. they use IE as
rendering engine, so their html support is very good.


-- bruce (sqlwork.com)
 
G

Guest

Get WebSuperGoo's ABCPDF, and look around more for the documentation and
"quick start." It is very well documented and easy to use; the "getting
started" stuff is as basic as can be.

-KF
 
C

Class

Hi Kenfine,

Thanks for your response but I must disagree with you.
IThe first product I checked out was the ABCPDF but...

There example of the conversion says:
virtual int AddHtml(string text)
virtual int AddHtml(string dummy, int chainid)


Doc theDoc = new Doc();
theDoc.FontSize = 72;
theDoc.AddHtml("<b>Gallia</b> est omnis divisa in partes tres, quarum unam
incolunt <b>Belgae</b>, aliam <b>Aquitani</b>, tertiam qui ipsorum lingua
<b>Celtae</b>, nostra <b>Galli</b> appellantur.");
theDoc.Save(Server.MapPath("docaddhtml.pdf"));
theDoc.Clear();

This example doesn't work.
In fact the AddHtml(string text) doesn't exists!!
I tried the version 5 of this component.

Thanks,
Class
 
R

Rob Roberts

Class,
Thanks for your response but I must disagree with you.
IThe first product I checked out was the ABCPDF but...

I agree with Kenfine. I've used AbcPdf.Net version 5, and it has worked
fine for me.

The way I typically use it is to write a function that creates the html
document and returns it as a string. This function creates a StringBuilder
and then repeatedly calls the StringBuilder's AppendLine method to add all
of the lines of the html file. Then I pass the html string returned by that
function to the Doc.AddImageHtml method. It has always worked fine for me.

--Rob Roberts
 
R

Rad [Visual C# MVP]

Hi all,

I am looking for some .NET code which can convert HTML to a PDF.
I have looked the internet bad without any luck so far.

I have found the iText.NET this has alot of sample but couldn't find a
sample for HTML to PDF.
Besides I get the error 'Provider for javax.xml.parsers.SAXParserFactory
cannot be found'
For every example I try.
Also the ABC PDF converter I tried but couldn't figure out how to get this
working also.
So little documentation :-(

Can somebody give me a simple example maybe?
Wihich DLL's I need for this conversion?

Many thanks,

Class

Try SharpPDF
 
C

Class

Hi Rob,

aha! okey, I will try the Doc.AddImageHtml method instead.
I'll let you know.

Thanks,
Class
 
P

prakash

You can try ABCpdf. which convert html to PDF

using (StreamReader sr = new StreamReader("just place full path of ur html file"))
while ((line = sr.ReadLine()) != null)
{
str = str + line + "\n";
}
Doc theDoc = new Doc();
theDoc.Rect.Inset(10, 50);
theDoc.Page = theDoc.AddPage();
int theID;
theID = theDoc.AddImageHtml(str);
while (true)
{
if (!theDoc.Chainable(theID))
break;
theDoc.Page = theDoc.AddPage();
theID = theDoc.AddImageToChain(theID);
}
for (int i = 1; i <= theDoc.PageCount; i++)
{
theDoc.PageNumber = i;
theDoc.Flatten();
}
theDoc.Save("path where u want 2 save"+pagedhtml.pdf");
theDoc.Clear();

EggHeadCafe.com - .NET Developer Portal of Choice
http://www.eggheadcafe.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,040
Latest member
papereejit

Latest Threads

Top