We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Add pdf memory stream to zip file not working

Thread ID:





105481 Oct 29,2012 06:47 PM UTC Nov 2,2012 05:13 AM UTC ASP.NET Web Forms (Classic) 1
Tags: PDF
Martin White
Asked On October 29, 2012 06:47 PM UTC

so I am creating a zip file of pdf documents, so I create  the pdf document( PdfDocument doc = new PdfDocument();)

//skipping code to convert to pdf from html here

After creating the pdf from html, I wrote the pdf into memory stream from below , then added it to a zip folder using the Iconic zip library.

But when I open the zip folder and click on the pdf file, it says 'adobe could not open the file'

What could the issue be? I thought I did everything properly

THanks for helping

MemoryStream stream = new MemoryStream();
  zipFile.AddEntry("file.pdf", "", stream);
  return new ZipFileResult(zipFile, "TexasExport.zip");

KarthikeyanC [Syncfusion]
Replied On November 2, 2012 05:13 AM UTC

Hi Martin,

Thank You for your interest in Syncfusion Products.


The error is due to the Stream Position.

When the document is saved in the stream(doc.Save(stream)), its current position moves to the end of file.

While creating the pdf file to add in to the zip folder the current position starts from EOF. So, the file created is empty.

Set the position to 0(zero) before creating the pdf file.


The code is as follows:

  MemoryStream stream = new MemoryStream();


            stream.Position=0;             //This line should be added

            zipFile.AddEntry("file.pdf", "", stream);

  return new ZipFileResult(zipFile, "TexasExport.zip");


Please let us know if you have any concern.





This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon