Aaditya Ganesan

Aaditya Ganesan

  • NA
  • 40
  • 46.5k

HTML to PDF with user input

Feb 25 2011 2:52 PM
Hey guys,
I am really tired running into problems on generating the PDF file form the HTML page.
Can any1 help me generate a PDF file from the HTML page along with the user input. My Aspx page does not have tables and cells,
It has combo box, text box and dropdowns just like a form used to enter details. I have a code right now working but it jus generates the PDF based on the URL. and my URL does not change for the values selected for each and every dropdowns, so it just simply generates the initial form without the inputs.
I have tried using all the possible HTML to PDF converts and nothing works even itextSharp, nw i am using WnVhtmltopdf and running into the above mentioned issue.
Can anyone look into my code and give me a solution on getting the PDF after the user input or suggest me with someother converter and working solution please..
PdfConverter pdfConverter = new PdfConverter();

 
  pdfConverter.PdfDocumentOptions.PdfPageSize = PdfPageSize.A4;

  pdfConverter.PdfDocumentOptions.PdfPageOrientation = PDFPageOrientation.Portrait;

  pdfConverter.PdfDocumentOptions.PdfCompressionLevel = PdfCompressionLevel.Normal;

 

  pdfConverter.PdfDocumentOptions.GenerateSelectablePdf = true;

 

  pdfConverter.PdfDocumentOptions.ShowFooter = false;
  pdfConverter.PdfDocumentOptions.ShowHeader = false;

  pdfConverter.LicenseKey = "Q2hzY3Jjc2N3bXNjcHJtcnFtenp6eg==";

  string a = Request.Url.ToString();

  byte[] downloadBytes = pdfConverter.GetPdfFromUrlBytes(a); 
 

  System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;

  response.Clear();

  response.AddHeader("Content-Type", "binary/octet-stream");

  response.AddHeader("Content-Disposition","attachment; filename=" + "Rendered.pdf" + "; size=" + downloadBytes.Length.ToString());

  response.Flush();

  response.BinaryWrite(downloadBytes);

  response.Flush();

  response.End();
Thanks in advance
Aaditya

Answers (9)