public void pdfgenforffd(TextBox TextBox3, HiddenField HiddenField1, HiddenField HiddenField4, AjaxControlToolkit.HTMLEditor.Editor Editor1)
{
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ContentType = "application/pdf";
Document pdfDocument = new Document(PageSize.A4, 50, 25, 15, 10);
PdfWriter wri = PdfWriter.GetInstance(pdfDocument, new FileStream("d://" + HiddenField1.Value + "_" + HiddenField4.Value + ".pdf", FileMode.Create));
PdfWriter.GetInstance(pdfDocument, HttpContext.Current.Response.OutputStream);
pdfDocument.Open();
string htmlText = Editor1.Content;
HTMLWorker htmlWorker = new HTMLWorker(pdfDocument);
htmlWorker.Parse(new StringReader(htmlText));
pdfDocument.Close();
HttpContext.Current.Response.End();
}
I use the above code to generate pdf from html text in HTMLEditor (ajax control). If I hard-code the table with each column of different widths into HTMLEditor text than when generating pdf, the column will be split equally. All columns have a fixed size on pdf, even if I specify some custom width for each column.
I want to create a pdf that can convert html to pdf, also split the table column with the specified width. How to do it?
source
share