SalvaMalaga
unread,Nov 24, 2009, 7:47:47 AM11/24/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
Hello, does anybody knows any method to generate .pdf files from html
files for FREE
I have tried with itextsharp library with the code:
Document document = new Document(PageSize.A4, 80, 50, 30,
65);
PdfWriter.GetInstance(document, new FileStream(“file.pdf”,
FileMode.Create));
Document.Open();
HtmlParser.Parse (document, “newfile.htm”);
Document.Close();
The thing is that i am getting the PDF file BUT this library is so
strict that i am missing the biggest part of the information in the
HTML file, so i had to delete lots of information. I cant afford this
because i am using templates and they are generating quite complex
html files.
So , again, does anybody know how to generate pdf from html??? i dont
need to phisically generate the file, i just need to print id in the
screen. For this i also tried this:
Response.Clear();
Response.AddHeader("content-disposition",
"attachment;filename=Test.pdf");
Response.Charset = "";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = "Application/pdf";
StringWriter sw1 = new StringWriter();
sw1.Write("<html><p align='center'>Hello World!</p></
html>");
//StreamWriter sw1 = File.CreateText(@"c:\temp
\ResortInformation.htm");
HtmlTextWriter htmlWrite = new HtmlTextWriter(sw1);
Page.RenderControl(htmlWrite);
Response.Write(sw1.ToString());
Response.End();
but does not work again...
If i change it to WORD format, it works, generating the right html
info (without html tags) but i need pdf not word...
Thanks in advance mates !!!