We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Blank Page is appended as first page with final PDF file


I am using trail version aspose pdf for .net for generating pdf file from filestream of aspx file which g enerates html filestream content and i am trying to generate pdf from this.
My problem is with aspose’s output pdf file is it is generating pdf file with empty blank page in the final pdf file.
I am attaching the output of final file for your reference and code which i am using for this requirement as well.

protected void btnPrint_Click(object sender, EventArgs e)
var rows = gvContactList.Rows;
// Instantiate an object PDF class
var pdf = new Pdf();
var doc = new Document(pdf);
// add the section to PDF document sections collection
var section = pdf.Sections.Add();
// Create Header Section of the document
Aspose.Pdf.Generator.HeaderFooter header = new Aspose.Pdf.Generator.HeaderFooter(section);
section.OddHeader = header;
section.EvenHeader = header;
//Create an image object in the section
Aspose.Pdf.Generator.Image image1 = new Aspose.Pdf.Generator.Image(section);
image1.ImageInfo.File =Server.MapPath(ConfigurationManager.AppSettings[“PDFHeaderImagePath”].ToString());
image1.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Gif;
// Create a Footer Section of the document.
Aspose.Pdf.Generator.HeaderFooter footer = new Aspose.Pdf.Generator.HeaderFooter(section);
section.OddFooter = footer;
section.EvenFooter = footer;
// Create a Text object
Aspose.Pdf.Generator.Text txt = new Aspose.Pdf.Generator.Text(“Page: ($p of $P ) “);
for (int i = 0; i < rows.Count; i++)
var chkBox = rows[i].FindControl(“chkBoxPrint”) as CheckBox;
var rowNo = gvContactList.DataKeys[rows[i].RowIndex].Value.ToString();
if (chkBox != null && chkBox.Checked)
var strWriter = new StringWriter();
byte[] data = AECrypt.EncryptWithSymmetricAid(rowNo, PublicKey);
var navistring = Convert.ToBase64String(data);
Server.Execute(string.Format(”~/pub/PDFGenerator.aspx?id={0}”, navistring), strWriter);
var info = new TextInfo();
info.Alignment = AlignmentType.FullJustify;
info.FontName = “Arial nicode MS”;
info.FontSize = 12f;
info.FontEncoding = “utf-8”;
info.IsUnicode = true;
info.TruetypeFontFileName = “Arial Unicode MS”;
//Create text paragraphs containing HTML text
Aspose.Pdf.Generator.Text txt1 = new Aspose.Pdf.Generator.Text(strWriter.ToString(), info);
txt1.IsFitToPage = true;
txt1.UseTextInfoStyle = true;
// enable the property to display HTML contents within their own formatting
txt1.IsHtmlTagSupported = true;
section.PageInfo.PageWidth = Aspose.Pdf.Generator.PageSize.A4Height;
section.PageInfo.PageHeight = Aspose.Pdf.Generator.PageSize.A4Width;
//Instantiate the MarginInfo instance
Aspose.Pdf.Generator.MarginInfo marginInfo = new Aspose.Pdf.Generator.MarginInfo();
marginInfo.Top = 42;
marginInfo.Bottom = 42;
marginInfo.Left = 40;
marginInfo.Right = 40;

// Assign the marginInfo instance to Margin property of section.PageInfo
section.PageInfo.Margin = marginInfo;

//Add the text paragraphs containing HTML text to the section
//// Assign a security instance to Pdf object
//pdf.Security = new Security();
//// Set the master password for the PDF document
//pdf.Security.MasterPassword = null;
//// Set the user password for the PDF document
//pdf.Security.UserPassword = “user”;
// Open the pdf file as stream in the browser window.
var stream = new MemoryStream();
Response.Charset = “UTF-8”;
Response.AddHeader(“Content-Length”, stream.Length.ToString());
Response.AddHeader(“content-disposition”, String.Format(“attachment;filename={0}.pdf”, GetActiveuser().DisplayName));
Response.ContentType = “application/pdf”;
catch (Exception ex)
throw ex;

Hi Kumar,

Thanks for contacting support.

I have noticed an extra blank page at first location in resultant PDF document. However, unless we have been able to replicate this problem in our environment, we might not be able to figure out the reasons of this issue.

Nevertheless, you can remove the blank page from resultant PDF by following the instructions specified over Delete a Particular Page from the PDF File.

I have also noticed that you are using an older release (8.9.0) and the current release is 9.3.0. I am not entirely certain, but you may try converting the HTML to PDF with latest release and see if it can resolve your problem. We are sorry for your inconvenience.

Thank you Nayyer for your support on this issue.

The issue is resolved as per your suggention and reference.

Thank you.

Hi Kumar,

We are pleased to hear that your problem is resolved. Please continue using our API and in the event of any further query, please feel free to contact.