I have a HTMLEditor(ajax control). i am converting the contents present in HTMLEditor into pdf as follows
protected void Button2_Click(object sender, EventArgs e)
{
String dbDate = DateTime.ParseExact(TextBox3.Text, "dd/mm/yyyy", null).ToString("yyyy-mm-dd");
//Extract data from Page (pd).
//Label16.Text = Editor1.Content; // Attribute
// makae ready HttpContext
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ContentType = "application/pdf";
// Create PDF document
Document pdfDocument = new Document(PageSize.A4, 80, 50, 30, 65);
PdfWriter wri = PdfWriter.GetInstance(pdfDocument, new FileStream("d://" + HiddenField1.Value + HiddenField4.Value + dbDate + ".pdf", FileMode.Create));
PdfWriter.GetInstance(pdfDocument, HttpContext.Current.Response.OutputStream);
pdfDocument.Open();
string htmlText = Editor1.Content;
System.Collections.Generic.List<IElement> htmlarraylist = HTMLWorker.ParseToList (new StringReader(htmlText), null);
for (int k = 0; k < htmlarraylist.Count; k++)
{
pdfDocument.Add((IElement)htmlarraylist[k]);
}
pdfDocument.Close();
HttpContext.Current.Response.End();
}
Now the problem is if i press enter in HTMLEditor, the generated pdf does not show any change .
I have already hardcoded some contents into HTMLEditor:
"<br/>" + "<P align= 'right'>"+"By Order of the Court,".Replace(Environment.NewLine,"<br/>")+"</P>" +
"<br/><br/>" + "<P align= 'right'>( G. M. Redker ) " +
"<br/>" + "Assistant Registrar " +
"<br/>" + "High Court of Bombay" +
"<br/>" + "Panaji Bench (Goa) " + "</P>";
now if i press enter before By Order of the Court the changes are not transferred to pdf file.
i.e if i press enter key after a line,than pdf does not show any gap between two lines it displays a continuous line.
All this happens only when i deploy application on server,my development machine shows a proper output.
Is this error because i am doing the followin:
string htmlText = Editor1.Content;
System.Collections.Generic.List<IElement> htmlarraylist = HTMLWorker.ParseToList (new StringReader(htmlText), null);
for (int k = 0; k < htmlarraylist.Count; k++)
{
pdfDocument.Add((IElement)htmlarraylist[k]);
}
Please help me to solve my problem
Normally, whitespace is collapsed in html, so this behavior seems normal. Use a <br/> tag to simulate a new line, or use <p></p> tags.