Click here to Skip to main content
15,891,725 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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;
Posted
Updated 8-Jul-19 4:23am

1 solution

A simple search via Google [^] netted this as the #1 result; sounds like your problem
[Html2PdfConverter] Extra blank page added to generated PDF[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900