Click here to Skip to main content
12,947,746 members (43,853 online)
Rate this:
 
Please Sign up or sign in to vote.
See more:
i have error : Object reference not set to an instance of an object.
when i execute below code.
plz give me solution.

string str = HTML.ToString(); // StringBuilder to string
        Document document = new Document(PageSize.A4, 20, 25, 35, 35);
        try
        {
 
            PdfWriter.GetInstance(document, new FileStream(Server.MapPath(".") + @"\Chap0101.pdf", FileMode.Create));
            document.Open();
 
            iTextSharp.text.Image pdfImage = iTextSharp.text.Image.GetInstance(Server.MapPath("~/images/logo.png"));
            pdfImage.ScaleToFit(100, 50);
            pdfImage.Alignment = iTextSharp.text.Image.UNDERLYING; pdfImage.SetAbsolutePosition(180, 760);
            document.Add(pdfImage);
 
            
            //HTMLWorker hw = new HTMLWorker(document);
            
 
            //here error occurs
            List<itextsharp.text.ielement> htmlarraylist = new List<ielement>(iTextSharp.text.html.simpleparser.HTMLWorker.ParseToList(new StringReader(str), null));</ielement></itextsharp.text.ielement>
            foreach (IElement element in htmlarraylist)
            {
                document.Add(element);
            }
                    
            document.Close();
            ShowPdf("Chap0101.pdf");
        }
        catch (Exception ex)
        {
 
        }


thanx in advace..
Posted 24-Sep-12 20:36pm
Updated 24-Sep-12 20:38pm
D-Kishore4.4K
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month
OriginalGriff 5,134
CHill60 3,275
Maciej Los 2,563
Jochen Arndt 1,935
ppolymorphe 1,795


Advertise | Privacy | Mobile
Web01 | 2.8.170518.1 | Last Updated 25 Sep 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100