Nreco converted my html code to pdf successfully but It created blank page at first page of pdf with number 5 for A4 page size and 104 for letter size.
Dim sw As New StringWriter()
Dim htw As New HtmlTextWriter(sw)
Panel1.RenderControl(htw)
Dim Converter As HtmlToPdfConverter = New HtmlToPdfConverter()
Dim htmlContent As String = sw.ToString()
Dim pdf As Byte() = Converter.GeneratePdf(sw.ToString(),PdfSharp.PageSize.Letter)
Response.Charset = "utf-8"
Response.ContentEncoding = System.Text.Encoding.UTF8
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Response.ContentType = "application/pdf"
Response.AddHeader("content-disposition", "attachment;filename=" + "test.pdf")
Response.Buffer = True
Response.BinaryWrite(pdf)
Response.Flush()
Response.Clear()
Response.End()
What I have tried:
I searched about this problem and test all below style but do not work.
page-break-before:avoid;
page-break-after:avoid;
page-break-inside :avoid;