I have a method where I am trying to save the document with custom properties. I am using the document.Save() to achieve it.
After updating to .NET 8, I am getting the following error for document Save methods. No overload for method ‘Save’ takes 4 arguments Code to save document:
It appears that after upgrading to .NET 8 and Aspose.Words 25.9.0, you are encountering an issue with the Save method due to a parameter count mismatch. The error message indicates that the method you are trying to call does not accept four arguments.
In the latest versions, the Save method for the Document class may have changed its overloads. You should verify the updated documentation for the correct method signature.
Here’s a possible adjustment to your code:
public static Aspose.Words.Saving.SaveOutputParameters SaveWithSensitivity(
Aspose.Words.Document document,
HttpResponse response,
string fileName,
Aspose.Words.Saving.SaveOptions saveOptions
) {
document.CustomDocumentProperties.Add("Label_Name", "Sensitive_Label");
document.CustomDocumentProperties.Add("Label_Type", "Sensitive");
// Check the correct overload for Save method
// Example: If the method now only takes 3 parameters
return document.Save(response, fileName, saveOptions);
}
Make sure to verify the correct parameters for the Save method in the latest Aspose.Words documentation. If the overloads have changed, you may need to adjust your method call accordingly.
If you continue to face issues, consider providing a minimal reproducible example in the Aspose forums for further assistance.
There are two options to chose in ContentDisposition, Attachment or Inline. How to achieve both? Is it possible to leverage HttpResponse from Microsoft.AspNetCore.Http namespace to achieve it. Can you provide an example on this scenario.
@rpmati Saving to response works as the following code:
using (MemoryStream stream = new MemoryStream())
{
doc.Save(stream, SaveFormat.Pdf);
Response.Clear();
//Specify the document type.
Response.ContentType = "application/pdf";
//Other options:
//Response.ContentType = "text/plain"
//Response.ContentType = "text/html"
//Specify how the document is sent to the browser.
Response.AddHeader("content-disposition", "attachment; filename=MyDocument.pdf");
//Another option could be:
//Response.AddHeader("content-disposition", "inline; filename=out.doc");
//Get data bytes from the stream and send it to the response.
byte[] bytes = stream.GetBuffer();
Response.BinaryWrite(bytes);
Response.End();
}
So you can implement the same approach in your code.