Skip to content
Loading
How to convert HTML Div to PDF in Asp.Net MVC with position?   
And in controller side, I am passing div as string. And in the controller side my code is like below :
  1. [HttpPost, ValidateInput(false)]    
  2. public FileResult HtmlToPdf(string GridHtml)    
  3. {    
  4.     var workStream = new MemoryStream();    
  5.     using(var pdfWriter = new PdfWriter(workStream))    
  6.     {    
  7.        pdfWriter.SetCloseStream(false);    
  8.        using(var document = HtmlConverter.ConvertToDocument(GridHtml, pdfWriter))    
  9.        {}    
  10.     }    
  11.     workStream.Position = 0;    
  12.     return new FileStreamResult(workStream, "application/pdf");    
  13. }  
So please guide me that how can I generate PDF from HTML Div which looks same as displayed in the browser. PDF should display a base64 image and also need to display all other div's text and value at the proper position. Please guide me to convert HTML Div to PDF as expected. 

So draggable div is not placing on pdf with proper position. Which we need to achieve. 

3 Replies

Know the answer? Post it — somebody with the same question will find it here.