# DocumentViewer.Save Method

> Initiates saving the currently loaded document. The actual saving is performed by a method which has to be bound to the DocumentServer.Web.DocumentViewer.SaveDocument event.

- **Product:** TX Text Control .NET Server
- **Section:** Reference
- **Kind:** Method
- **Introduced:** 15.0
- **Namespace:** `TXTextControl.DocumentServer.Web`
- **Package:** `TXTextControl.TextControl.ASP.SDK` (assembly `TXDocumentServer.Web.DocumentViewer.dll`, from the private NuGet feed or Text Control Offline Packages)
- **.NET Framework:** reference `TXDocumentServer.Web.DocumentViewer.dll` from the setup
- **Path:** TX Text Control .NET Server > Reference > TXTextControl.DocumentServer.Web > DocumentViewer.Save Method
- **990 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol-documentserver-web/documentviewer/save-method/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol-documentserver-web/documentviewer/save-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol-documentserver-web/documentviewer/save-method/llms-full.txt

---

### Description

Initiates saving the currently loaded document. The actual saving is performed by a method which has to be bound to the [DocumentServer.Web.DocumentViewer.SaveDocument](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol-documentserver-web/documentviewer/savedocument-event/llms-full.txt) event.

### Syntax

#### Save(FileFormat)

Saves the document in a specific document format.

```csharp
public void Save(FileFormat format);
```

```vbnet
Public Sub Save(format As FileFormat)
```

| Parameter | Description |
|---|---|
| format | Specifies one of the [DocumentServer.FileFormat](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol-documentserver/fileformat/enumeration/llms-full.txt) values. |

#### Save(string)

Saves the document to a specific path.

```csharp
public void Save(string path);
```

```vbnet
Public Sub Save(path As String)
```

| Parameter | Description |
|---|---|
| path | Specifies where the document should be saved. |

#### Save(string, FileFormat)

Saves the document to a specific path in a specific document format.

```csharp
public void Save(string path, FileFormat format);
```

```vbnet
Public Sub Save(path As String, format As FileFormat)
```

| Parameter | Description |
|---|---|
| path | Specifies where the document should be saved. |
| format | Specifies one of the [DocumentServer.FileFormat](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol-documentserver/fileformat/enumeration/llms-full.txt) values. |

### Examples

`DocumentServer.Web.DocumentViewer.Save` belongs to the legacy Web Forms viewer. In the current ASP.NET Core viewer, configure the server-rendered component through `DocumentViewerSettings.DocumentPath`; interactive page state and styling are handled by the viewer client.

```csharp
documentViewerSettings.DocumentPath = @"App_Data\document.docx";
if (!string.IsNullOrWhiteSpace(documentViewerSettings.DocumentPath))
{
    Console.WriteLine($"Document Path: {documentViewerSettings.DocumentPath}");
}
```

```vbnet
documentViewerSettings.DocumentPath = "App_Data\document.docx"
If Not String.IsNullOrWhiteSpace(documentViewerSettings.DocumentPath) Then
    Console.WriteLine($"Document Path: {documentViewerSettings.DocumentPath}")
End If
```

### Remarks

A given path is always relating to the server the document viewer is runnig on. Thus, it is good practice to define the path parameter using the `HttpServerUtility.MapPath()` method.

---

## Nearby

- **Previous:** [DocumentViewer.RoundedPageCorners Property](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol-documentserver-web/documentviewer/roundedpagecorners-property/llms-full.txt)
- **Next:** [DocumentViewer.SaveDocument Event](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol-documentserver-web/documentviewer/savedocument-event/llms-full.txt)
