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

Free Support Forum - aspose.com

PDF file not downloading

Hello,

I used the Apose.PDF component to create my PDFs and they work fine until deployed to our production servers. Instead of allowing the users to download the actual PDF file, it tried to download the .aspx page. The live website is a SSL website. Attached is a screenshot of the dialogue box showing what IE is trying to download. Is there any known issues with the PDF component with SSL sites? Is so, can you please provide a work around? This project is for a very large client. Please help.

Below is my coding for instantiating the PDF object.

Pdf pdf1 = new Pdf();

pdf1.Save("SplitBillPDF", Aspose.Pdf.SaveType.OpenInAcrobat, this.Response);

Hi,

I think the pdf is till being downloaded, the problem is that the file name in the download dialog is incorrect. Please download the file and rename it to pdf and open it in Adobe Reader, this will verify that the pdf is indeed being downloaded. For information on how to correct the file name please consult http://classicasp.aspfaq.com/files/directories-fso/how-do-i-send-the-correct-filename-with-binarywrite.html

Thanks.

I want to add more comment. We have not tested with SSL. Aspose.Pdf uses the following code to send pdf to browser:

response.Clear();
//added 2007-4-23
response.ClearContent();
response.ClearHeaders();

if(saveType == SaveType.OpenInAcrobat) response.AddHeader(“content-disposition”,“attachment; filename=” + fileName);
else
response.AddHeader(“content-disposition”,“inline; filename=” + fileName);
response.ContentType = “application/pdf”;

response.BinaryWrite(buf);
response.Flush();


You can try saving the Pdf into stream and send the stream to browser by yourself.

We tried your suggestion but still got the same dialogue box. The first common was not correct. When the user tried to save the aspx being downloaded, it generated different error message.

We recently purchased your product just for this client and all of our websites are using SSL. Can you please provid us a work around? It would be greatly appreciated.

I think you can google this issue and try to find a solution. Please refer to the following links:
http://www.ajaxline.com/node/358
http://www.thescripts.com/forum/thread328488.html

Thanks for the links.

I have the following code which works for downloading CSV files. I would like to try it for downloading the PDFs. However I need to need the full path (strFilenameFull referenced below) of where pdf is residing on the server. Can you please let me know?

System.IO.FileStream myStream = new System.IO.FileStream(strFilenameFull, System.IO.FileMode.Open, System.IO.FileAccess.Read);

int iFileSize = (int)myStream.Length;

Byte[] bytBuffer = new byte[myStream.Length];

myStream.Read(bytBuffer, 0, (int)myStream.Length);

myStream.Close();

page.Response.Clear();

page.Response.ClearHeaders();

page.Response.ClearContent();

page.Response.ContentType = "application/pdf";

page.Response.Charset = "UTF-8";

page.Response.AddHeader("Content-Length", iFileSize.ToString());

page.Response.AddHeader("Content-Disposition", "attachment; filename=" + _SaveAsFileName);

page.Response.BinaryWrite(bytBuffer);

page.Response.Flush();

page.Response.End();

For people who are experiencing the same problem, below is the code which fixed my SSL issue with downloading PDFs:

//Saves file to memory

MemoryStream stream = new MemoryStream();

pdf1.Save(stream);

Response.Clear();

Response.ClearHeaders();

Response.ClearContent();

Response.Charset = "UTF-8";

Response.AddHeader("Content-Length", stream.Length.ToString());

Response.AddHeader("content-disposition", String.Format("attachment;filename={0}", _SaveAsFileName));

Response.ContentType = "application/pdf";

Response.BinaryWrite(stream.ToArray());

Response.Flush();

Response.End();