Google for itextsharp

On Nov 25, 2009 12:32 PM, "SalvaMalaga" <[email protected]> wrote:

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 !!!

Reply via email to