> For the complete documentation index, see [llms.txt](https://docs.apryse.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.apryse.com/xamarin/basic-operations/save.md).

# Saving documents in Xamarin

Learn how to save PDF documents using PDFTron's saving APIs from the PDFDoc class. Explore different saving modes like removing unused objects, incremental saving, and linearized format for optimized

Use PDFron saving APIs from `PDFDoc` class to save PDF documents on local storage.

## Saving by path

To save a PDF document to path use:

{% tabs %}
{% tab title="C#" %}
{% code lineNumbers="true" %}

```csharp
pdfdoc.Save(Utils.CreateExternalFile(filepath), pdftron.SDF.SDFDoc.SaveOptions...);
```

{% endcode %}
{% endtab %}
{% endtabs %}

For example, to save for optimized file streaming, use:

{% tabs %}
{% tab title="C#" %}
{% code lineNumbers="true" %}

```csharp
pdfdoc.Save(Utils.CreateExternalFile(filepath), pdftron.SDF.SDFDoc.SaveOptions.e_linearized);
```

{% endcode %}
{% endtab %}
{% endtabs %}

## Saving modes

There are a few ways to save a PDF document on permanent storage such as save with remove unused objects, save incrementally, save in linearized format, etc.

### Save with remove unused objects `SaveOptions.e_remove_unused`

This mode saves disk storage space by rearranging the PDF document and removing unused objects. As a result, the output file can be significantly smaller. However, the saving process itself may take longer compared to incremental mode.

### Save incrementally `SaveOptions.e_incremental`

Use the incremental mode if you are particularly concerned about the time it takes to save the file. If you use this mode, any changes to the document, even the deletion of annotations, will be appended to the end of the PDF file. Note that it is not possible to incrementally save the document if the underlying file has an XRef table that had to be repaired when the file was opened (see <https://groups.google.com/forum/#!msg/pdfnet-sdk/GZwt_U16ipw/zhq43GQnNlYJ>).

### Save in linearized format `SaveOptions.e_linearized`

This mode is to be preferentially used in file streaming situations, such as when you want to upload a PDF document. A linearized PDF file is a PDF file that is structured in a way that allows the first page of the PDF file to be displayed in a user's device before the entire file is downloaded from the Web server. If you're developing a system that creates large PDF files for delivery to client, you should try to make sure that your system can generate linearized PDF files. Your users might become frustrated and impatient if your system creates large PDF files that are not linearized, because it could take 30 seconds or even longer for a user's device to display a large PDF file that is not linearized. PDF linearization is also know as 'fast web view'.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.apryse.com/xamarin/basic-operations/save.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
