Click here to Skip to main content
14,239,876 members
Rate this:
Please Sign up or sign in to vote.
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

Rate this:
Please Sign up or sign in to vote.

Solution 1

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

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100