Hello, I am using the FreeTextBox control to write the text, which then I want 
to export to pdf. I am using iText# of course. all works very nicely untill I 
use the <hr> tag, (the insert rule button). when I want to export to pdf, I get 
the error.This is the C# code I use: private byte[] RanderHTMLtoPDF(string html)
    {
        byte[] doc = null;        iTextSharp.text.Document idocument = new 
iTextSharp.text.Document(iTextSharp.text.PageSize.A4, 32, 32, 50, 50);
        using (MemoryStream m = new MemoryStream())
        {
            iTextSharp.text.pdf.PdfWriter.GetInstance(idocument, m);
            idocument.Open();            using (TextReader sReader = new 
StreamReader(new MemoryStream(System.Text.Encoding.Default.GetBytes(html)), 
Encoding.Default))
            {
                iTextSharp.text.html.simpleparser.HTMLWorker worker = new 
iTextSharp.text.html.simpleparser.HTMLWorker(idocument);
                worker.StartDocument();
                worker.Parse(sReader);
                worker.EndDocument();
            }
            idocument.Close();            doc = m.ToArray();
        }
        return doc;
    } At the worker.Parse(sReader); it crashes. the error is:ERROR: Object 
reference not set to an instance of an object.                              
SOURCE: itextsharpSTACK TRACE:    at 
iTextSharp.text.html.simpleparser.HTMLWorker.CreateLineSeparator(IDictionary`2 
attrs)   at 
iTextSharp.text.html.simpleparser.HTMLTagProcessors.HTMLTagProcessor_HR.StartElement(HTMLWorker
 worker, String tag, IDictionary`2 attrs)   at 
iTextSharp.text.html.simpleparser.HTMLWorker.StartElement(String tag, 
IDictionary`2 attrs)   at 
iTextSharp.text.xml.simpleparser.SimpleXMLParser.ProcessTag(Boolean start)   at 
iTextSharp.text.xml.simpleparser.SimpleXMLParser.Go(TextReader reader)   at 
iTextSharp.text.xml.simpleparser.SimpleXMLParser.Parse(ISimpleXMLDocHandler 
doc, ISimpleXMLDocHandlerComment comment, TextReader r, Boolean html)   at 
iTextSharp.text.html.simpleparser.HTMLWorker.Parse(TextReader reader)   at 
ExportPDF.RanderHTMLtoPDF(String html) in 
d:\Lucru\Proiecte\CRMTravel\CRM\App_Code\Framework\PDF\ExportPDF.cs:line 383   
at ExportPDF.SaveToPDF(Int32 copyNo, String html) in 
d:\Lucru\Proiecte\CRMTravel\CRM\App_Code\Framework\PDF\ExportPDF.cs:line 422   
at ExportContractPJ..ctor(Int32 id, String title)  I really hope you could help 
me, I took over this from a colegue that left, and I am really stuck. Thanks in 
advance,Gabriel                                           
------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference 
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: 
http://itextpdf.com/themes/keywords.php

Reply via email to