0

My iTextSharp Code is like below I am using XSLT for getting HTML design:

int pageCount = GetNoofPages(outputString);
StringReader sr = new StringReader(outputString.Replace("###Noofpages###", pageCount.ToString()));
byte[] content = null;
string savedfile = string.Empty;
using (MemoryStream myMemoryStream = new MemoryStream())
{
    iTextSharp.text.Document pdfDoc = new iTextSharp.text.Document(PageSize.A4, 40f, 10f, 40f, 36);
    HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
    StyleSheet style = new StyleSheet();
    htmlparser.SetStyleSheet(style);
    PdfWriter myPDFWriter = PdfWriter.GetInstance(pdfDoc, myMemoryStream);
    pdfDoc.Open();
    htmlparser.Parse(sr);
    HTMLWorker htmlparser1 = new HTMLWorker(pdfDoc);
    StyleSheet style1 = new StyleSheet();
    htmlparser1.SetStyleSheet(style1);
    pdfDoc.Close();
    content = AddPageNumbers(myMemoryStream.ToArray());
}                 
return content;

My output is:

Leg 1: 4311 route
// Now rest of the page is blank
.
.
.
.
.
// Now it will continue on next page
Route details:
// remaining instructions

Please help me.

Chris Haas
  • 53,986
  • 12
  • 141
  • 274
Tejas Thakor
  • 97
  • 12
  • `HTMLWorker` is deprecated and hasn't been supported for years now. It was abandoned in favor of iTextSharp's XML Worker. Furthermore: you create `htmlparser1`, but you're never using it. All in all, your question is unclear. There is too much information missing for anyone to answer it, although it looks very similar to the question [How to parse multiple HTML files into a single PDF?](http://stackoverflow.com/questions/27814701) – Bruno Lowagie Nov 24 '15 at 08:47
  • Thanks now how to replace HTMLWorker ? – Tejas Thakor Nov 24 '15 at 09:51
  • 1
    The best place to start is [here](http://stackoverflow.com/questions/25164257/how-to-convert-html-to-pdf-using-itextsharp). But there are plenty of other examples on SO. See also [The Best iText Questions on StackOverflow](http://pages.itextpdf.com/ebook-stackoverflow-questions.html), a free ebook that has a complete chapter about XML Worker. – Bruno Lowagie Nov 24 '15 at 09:54

0 Answers0