c# - how to convert html page to pdf with css using itextsharp? -


this code :

response.contenttype = "application/pdf"; response.addheader("content-disposition", "attachment;filename=testpage.pdf"); response.cache.setcacheability(httpcacheability.nocache);  stringwriter sw = new stringwriter(); htmltextwriter hw = new htmltextwriter(sw);  this.page.rendercontrol(hw);  stringreader sr = new stringreader(sw.tostring());  document pdfdoc = new document(pagesize.a4, 10f, 10f, 100f, 0f);  htmlworker htmlparser = new htmlworker(pdfdoc);  pdfwriter.getinstance(pdfdoc, response.outputstream);  pdfdoc.open();  **htmlparser.parse(sr);** //the exception here  pdfdoc.close(); response.write(pdfdoc); response.end(); 

the error :

unable cast object of type 'itextsharp.text.html.simpleparser.cellwrapper' type 'itextsharp.text.paragraph'.

what exception ?

i don't know if answer, found itextsharp picky having valid html. tests had table opened twice , never closed , took hour me notice. exception similar 1 have there.


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -