Response Write Aspose Generated PDF

Can I ask on how to properly create a download mechanism using the generated file of aspose. My problem is that sometimes it downloads the page name ie. “mypage.aspx” it must be “filedownload.pdf”

it only happens in pdf.

here is my code

doc.Save(Convert.ToString(HttpContext.Current.Server.MapPath(docfileName)), Aspose.Words.Saving.SaveOptions.CreateSaveOptions(SaveFormat.Pdf));
byte[] fileInBytes = System.IO.File.ReadAllBytes(Convert.ToString(HttpContext.Current.Server.MapPath(docfileName)));
using (MemoryStream ms = new MemoryStream(fileInBytes))
{
    long dataLengthToRead = ms.Length;
    int blockSize = dataLengthToRead >= 5000 ? 5000 : (int)dataLengthToRead;
    byte[] buffer = new byte[dataLengthToRead];
    Response.Clear();
    // Clear the content of the response
    Response.ClearContent();
    Response.ClearHeaders();
    // Buffer response so that page is sent
    // after processing is complete.
    Response.BufferOutput = true;
    // Add the file name and attachment,
    // which will force the open/cance/save dialog to show, to the header
    // Response.AddHeader("Content-Disposition", "attachment; filename=" + strFile);
    // bypass the Open/Save/Cancel dialog
    Response.AddHeader("Content-Disposition", "attachment; filename=" + strFile);
    // Add the file size into the response header
    Response.AddHeader("Content-Length", fileInBytes.Length.ToString());
    // Set the ContentType
    Response.ContentType = "application/pdf";
    while (dataLengthToRead > 0 && Response.IsClientConnected)
    {
        Int32 lengthRead = ms.Read(buffer, 0, blockSize);
        Response.OutputStream.Write(buffer, 0, lengthRead);
        dataLengthToRead = dataLengthToRead - lengthRead;
    }
    Response.Flush();
    Response.Close();
}
// End the response
Response.End();

Thanks

Hi Joebet,

Thanks
for your inquiry.

We have already written an article in API documentation that outlines how to send a Word document to client’s browser. Please read it here:
https://docs.aspose.com/words/net/save-a-document/

Hope this helps you. Please let us know if you have any more queries.

[quote user=“tahir.manzoor”]Hi Joebet,

Thanks
for your inquiry.

We have already written an article in API documentation that outlines how to send a Word document to client’s browser. Please read it here:
https://docs.aspose.com/words/net/save-a-document/

Hope this helps you. Please let us know if you have any more queries.

[/quote]

Theres no overload available for what you had given me. and we are using the latest license copy found on your download page.

Hi Joebet,

Thanks for your inquiry. Please use the Aspose.Words DLL from net2.0 folder. It will serve your purpose. Please read the overloaded methods of Document.Save from here:
https://reference.aspose.com/words/net/aspose.words/document/save/

Moreover, the net3.5_ClientProfile folder contains assemblies to use with .NET Framework 3.5 or 4.0 Client Profile. Note that this assembly excludes the Save overload accepting an HttpResponse object. This is by design as the client profile excludes System.Web assembly.

Hope this answers your query. Please let us know if you have any more queries.