DocumentSave(HttpResponse, String, ContentDisposition, SaveOptions) Method |
public SaveOutputParameters Save( HttpResponse response, string fileName, ContentDisposition contentDisposition, SaveOptions saveOptions )
Internally, this method saves to a memory stream first and then copies to the response stream because the response stream does not support seek.
Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); builder.InsertField(" MERGEFIELD FullName "); builder.InsertParagraph(); builder.InsertField(" MERGEFIELD Company "); builder.InsertParagraph(); builder.InsertField(" MERGEFIELD Address "); builder.InsertParagraph(); builder.InsertField(" MERGEFIELD City "); doc.MailMerge.Execute(new string[] { "FullName", "Company", "Address", "City" }, new object[] { "James Bond", "MI5 Headquarters", "Milbank", "London" }); // Send the document to the client browser. Assert.That(() => doc.Save(response, "Artifacts/MailMerge.ExecuteArray.docx", ContentDisposition.Inline, null), Throws.TypeOf<ArgumentNullException>()); //Thrown because HttpResponse is null in the test. // We will need to close this response manually to ensure that we do not add any superfluous content to the document after saving. Assert.That(() => response.End(), Throws.TypeOf<NullReferenceException>());