asp.net - iTextSharp error: 'HtmlParser' is not declared -
i had import following namespace in asp.net page
imports itextsharp
imports itextsharp.text
imports itextsharp.text.pdf
imports itextsharp.text.html
but still got error 'htmlparser' not declared when compile, what's problem ?
thanks
protected sub btn_print_click(byval sender object, byval e system.eventargs) handles btn_print.click 'get html gridview1 dim sw new io.stringwriter() dim htw new htmltextwriter(sw) gridview1.rendercontrol(htw) dim html string = "<html><body>" + sw.tostring() + "</body></html>" dim filename string = "temp" httpcontext.current.response.addheader("content-disposition", "attachment;filename=" + filename + ".pdf") 'set response response.clear() response.contenttype = "application/pdf" 'create pdf document dim document new itextsharp.text.document(pagesize.a4, 80, 50, 30, 65) 'create pdf writer, output directly outputstream dim writer itextsharp.text.pdf.pdfwriter = pdfwriter.getinstance(document, response.outputstream) document.open() 'create tempfile hold html: dim tempfile string = path.gettempfilename() using tempwriter new io.streamwriter(tempfile, false) tempwriter.write(html) end using 'parse html document htmlparser.parse(document, tempfile) 'cleanup document.close() writer.close() 'delete tempfile: file.delete(tempfile) writer = nothing document = nothing response.[end]() end sub
Comments
Post a Comment