Editor for WinForms
読み込みと保存

Editor provides built-in options to load and save the documents. Let us explore these options in the following sections.

Load Documents

With Editor, you can easily load the stored documents. Loading the stored documents also helps in reducing your time and effort in re-creating them. You can use Load option from the Quick Access Toolbar to load a document at runtime. Besides this, you can use LoadDocument and LoadDocumentRequest methods of the C1Editor class to deserialize the data from the XML or XHTML file. The LoadDocument method loads the specified document whereas the LoadDocumentRequest method opens the file dialog to load the selected document.

The following code demonstrates how to load a document in Editor using the LoadDocument method. In this example, the content gets loaded from a file named tesla.html.

C#
コードのコピー
c1Editor1.LoadDocument(@"C:\tesla.html");

Save Documents

You can save your documents with Editor at runtime by using Save option from the Quick Access Toolbar. Besides this, you can use SaveDocument and SaveDocumentRequest methods of the C1Editor class. The SaveDocument method saves the specified document whereas the SaveDocumentRequest method opens the file dialog to save the Editor content to the selected file.

The following code snippet demonstrates how to save the Editor's content to a file using the SaveDocument method. In this example, the content gets saved to a file named Demo.html in the bin directory of the project folder.

C#
コードのコピー
c1Editor1.SaveDocument("Demo.html");

Save Document to PDF

PDF is one of the most commonly used formats to share the documents as it preserves formatting. Editor lets you save the documents as PDF using SaveDocumentToPDF method of the C1Editor class. This method accepts the absolute path of the location to save the document. In the following example, the document is saved as TestDemo.pdf in the Resources directory of the project folder.

C#
コードのコピー
c1Editor1.SaveDocumentToPDF(@"\Resources\TestDemo.pdf");