Issue using PrintLargePDF method

I have a question.....I have both Aspose.Pdf and Aspose.Pdf.Kit installed. I am dynamically generating a PDF in my solution. I am storing data as HTML in a stringbuilder and then writing it to a MemoryStream. I then use the BindHTML method of the PDF object to bind the data from the MemoryStream and then the GetBuffer method to convert it to a byte array to render to the browser....It works fine but the problem I am having is for very large files, the largest being about 600 pages/1.7mb. It takes about 25 minutes to run and sometimes times out. I tried to use the PrintLargePDF method of Aspose.Pdf.Kit. When I pass it the MemoryStream I get a corrupt files or too many pages error. I am not working with files here just data temporarily stored in a MemoryStream. I will paste existing code below. PrintLargePDF section commented out in Report function Also...If I set IsBuffered to false, what would I use instead of GetBuffer? Does using the CompressionValue = maximum of 9 help? Thanks as this is new to m

int individualOrderId = Request.QueryString["individualOrderId"] == null?0:Convert.ToInt32(Request.QueryString["individualOrderId"]);

StringBuilder orderText = new StringBuilder("");

string pdfNm = string.Empty;

Aspose.Pdf.License license = new License();

license.SetLicense(AppDomain.CurrentDomain.BaseDirectory + @"\Aspose.Total.lic");

pdfNm = "batch_pdf";

string[] arrSSN = (string[])HttpContext.Current.Session["arrSSN"];

List<CTCS.Bol.IndividualOrder> list = IndividualOrderService.getBatchList(arrSSN);

for (int i = 0; i < list.Count; i++)

orderText.Append(list[i].OrderText);

orderText = orderText.Replace("

", "");

orderText = orderText.Replace("

", "");

MemoryStream objHTMLStream = new MemoryStream(ASCIIEncoding.UTF8.GetBytes(orderText.ToString()));

//Convert the memorystream to a PDF stored as a byte array.

byte[] theData = Report(objHTMLStream, this.Page);

//Clean up the memory stream

objHTMLStream.Flush();

objHTMLStream.Close();

// Clear all content output from the buffer stream

Response.Clear();

Response.Charset = "UTF-8";

// Set the HTTP MIME type of the output stream

Response.ContentType = "application/pdf";

// Add a HTTP header to the output stream that specifies the filename for appropriate browser

if (Request.Browser.Browser.ToString() == "IE")

Response.AppendHeader("content-disposition", string.Format("attachment; filename={0}.PDF", pdfNm));

else

Response.AppendHeader("content-disposition", string.Format("attachment; filename=\"{0}\".PDF", pdfNm));

//Add a HTTP header to output stream to let the browser know how much data is being transfered

Response.AddHeader("content-length", theData.Length.ToString());

//Write the data out to the client.

Response.BinaryWrite(theData);

Response.End();

}

private static byte[] Report(MemoryStream objStream, Page ObjPage)

{

Pdf pdf1 = null;

// Aspose.Pdf.Kit.PdfViewer viewer = new Aspose.Pdf.Kit.PdfViewer();

//viewer.AutoResize = true; //print the file with adjusted size

// viewer.AutoRotate = true; //print the file with adjusted rotation

// viewer.PrintPageDialog = true;//do not produce the page number dialog when printing

// viewer.PrintLargePdf(objStream);

// viewer.ClosePdfFile();

try

{

pdf1 = new Pdf();

System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Ssl3;

pdf1.HtmlInfo.PageHeight = PageSize.A4Height;

pdf1.HtmlInfo.PageWidth = PageSize.A4Width;

pdf1.HtmlInfo.Margin.Top = 30;

pdf1.HtmlInfo.Margin.Bottom = 30;

pdf1.HtmlInfo.Margin.Left = 20;

pdf1.HtmlInfo.Margin.Right = 20;

pdf1.HtmlInfo.ImgUrl = "~/app_themes/Image/";

pdf1.IsAutoFontAdjusted = true;

pdf1.DefaultFontName = "Times New Roman";

pdf1.CompressionLevel = 9;

pdf1.Author = "DAMPSU_2008jb";

pdf1.Creator = "MKGCS-jb";

pdf1.BindHTML(objStream);

////added this section for custom page numbering on PDF ....

foreach (Section sec in pdf1.Sections)

{

HeaderFooter footer = new HeaderFooter(sec);

sec.OddFooter = footer;

sec.EvenFooter = footer;

Text txt = new Text("Page: $p/$P ");

txt.TextInfo.Alignment = AlignmentType.Center;

txt.TextInfo.FontName = "Times New Roman";

txt.TextInfo.FontSize = 10;

footer.Paragraphs.Add(txt);

}

}

catch (Exception e)

{

ObjPage.Response.Write("Report(): " + e.Message);

ObjPage.Response.End();

}

if (pdf1 != null)

//Return the PDF document as a byte array

return pdf1.GetBuffer();

return null;

}

}

}

Thanks for any assistance you can provide....

David

Hi David,

Can you please clarify the issue a little bit? As I can see, you’re trying to create a new PDF file from HTML using Aspose.Pdf. I’m not sure why you’re trying to use PrintLargePDF method, because it is used only when you want to print a large PDF file on a printer. If you’re having problem while printing the large PDF file on printer then please share the problematic PDF file with us, so we could test it at our end. However, if you’re having trouble creating a PDF file from HTML then please do let us know, so I could move this thread to the related forum.

We’re sorry for the inconvenience.
Regards,