[]
        
(Showing Draft Content)

Loading and Saving Documents

Editor provides built-in functionality for loading and saving documents at runtime. These capabilities support document persistence and reduce the need to recreate existing content manually.


Load Documents

Editor supports loading previously saved documents through both UI commands and programmatic APIs.

Documents can be loaded interactively through the Load option in the Quick Access Toolbar or programmatically through the LoadDocumentAsync and LoadDocumentRequestAsync methods of the C1Editor class.

  • LoadDocumentAsync loads a specified document directly from a file.

  • LoadDocumentRequestAsync opens a file selection dialog and loads the document selected by the user.

Both methods deserialize document content from supported XML or XHTML formats into the editor.

The following example demonstrates loading a document from the tesla.html file using LoadDocumentAsync.

await c1Editor1.LoadDocumentAsync(@"C:\tesla.html");

Save Documents

Editor supports saving document content at runtime through both UI commands and programmatic APIs.

Documents can be saved interactively through the Save option in the Quick Access Toolbar or programmatically through the SaveDocumentAsync and SaveDocumentRequestAsync methods of the C1Editor class.

  • SaveDocumentAsync saves the document to a specified file.

  • SaveDocumentRequestAsync opens a file dialog that allows the user to select the save location and file name.

The following example saves the editor content to a file named Demo.html:

await c1Editor1.SaveDocumentAsync("Demo.html");

Note: Custom font colors may not be preserved correctly when exporting documents to RTF format.

Limitation: Text highlighting applied through highlight formatting is not supported in exported RTF files.


Save Document to PDF

PDF is a commonly used document format for sharing content because it preserves document layout and formatting consistently across environments.

Editor supports PDF export through the SaveDocumentToPDFAsync method of the C1Editor class. This method saves the current document content as a PDF file at the specified absolute file path.

The following example saves the document as TestDemo.pdf in the Resources directory of the project folder:

await c1Editor1.SaveDocumentToPDFAsync(@"\Resources\TestDemo.pdf");