Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 0f); HTMLWorker htmlparser = new HTMLWorker(pdfDoc); PdfWriter.GetInstance(pdfDoc, Response.OutputStream); string pdfFileName = Request.PhysicalApplicationPath + "\\files\\" + "DeliveryChalan" + FileName + ".pdf"; string appPath = HttpContext.Current.Request.ApplicationPath; string path = Server.MapPath(appPath + "\\files\\" + "DeliveryChalan" + FileName + ".pdf"); dynamic output = new FileStream(path, FileMode.Create); iTextSharp.text.pdf.PdfWriter.GetInstance(pdfDoc, output); //PdfWriter writer= iTextSharp.text.pdf.PdfWriter.GetInstance(pdfDoc, output); //writer.PageEvent = new Footer(); pdfDoc.Open(); //Paragraph welcomeParagraph = new Paragraph("Hello, World!"); //pdfDoc.Add(welcomeParagraph); for (int i = 1; i <= 4; i++) { string Id = "pnldata" + i; Panel pnl = (Panel)FindControl(Id); using (StringWriter sw = new StringWriter()) { using (HtmlTextWriter hw = new HtmlTextWriter(sw)) { pdfDoc.SetPageSize(new Rectangle(595, 850)); var style = new StyleSheet(); style.LoadTagStyle("body", "size", "9px"); //style.LoadTagStyle("grdDeliverChallan2", "height", "500px"); htmlparser = new HTMLWorker(pdfDoc); //htmlparser.SetStyleSheet(style); //pdfDoc.PageSize.Height = 10; pdfDoc.NewPage(); //pdfDoc.PageSize //const string V = @"vshsd"; //Chunk c1 = new Chunk("A chunk represents an isolated string. "); //ColumnText.ShowTextAligned(writer.DirectContent, Element.ALIGN_RIGHT, V, 36, 820, 0); pnl.RenderControl(hw); StringReader sr = new StringReader(sw.ToString()); htmlparser.Parse(sr); } } } pdfDoc.Close();
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)