Naming the saved pdf

Hi,

When I try to save the file after it loads, The file name ends up taking the name of the browser page. This is what I'm using below.

resultDoc.Save("myfile.pdf", Aspose.Words.SaveFormat.Pdf, Aspose.Words.SaveType.OpenInBrowser, Response);

How do I get it to use the filename called "myfile.pdf"?

Thanks

Hi Mike,


Thanks for your inquiry. Perhaps, you’re using an older version of Aspose.Words. I would suggest you please upgrade to the latest version of Aspose.Words i.e. 11.2.0 from the following link:
http://www.aspose.com/community/files/51/.net-components/aspose.words-for-.net/default.aspx

Then please use the following overload of Document.Save method to send the document to the client browser.

public SaveOutputParameters Save(
HttpResponse response,
string fileName,
ContentDisposition contentDisposition,
SaveOptions saveOptions
);

Please use the following code snippet to be able to pass a custom document name and send the document to the browser inline:

// Open an existing document.
Document doc = new
Document(MyDir + “MailMerge.ExecuteArray.doc”);

// Send the document in Word format to
the client browser with an option to save to disk or open inside the current
browser.
doc.Save(Response, “DocumentName.doc”, ContentDisposition.Inline,
null);

I hope, this will help.

Best Regards,

Your example, isn’t quite what we need here. We take the doc and save the output as a .pdf, not a .doc file. When we use your example and have the outputfilename = Document.doc it pops up a window asking to OPEN or SAVE and it is named ok. However, if our output id DocumentName.pdf, it loaded the PDF in the browser window, and the SAVE still picked up the aspx name instead of DocumentName.pdf

I am using 11.2, with .net 4 (the full version, not client profile) and I don’t see that signature as an option.

Hi there,


Thanks for this additional information.

Please make sure you are referencing the Aspose.Words DLLs under the .net2.0 folder. Using this DLL you should see the method overload Awais is talking about.

Thanks,