diff --git a/net/developer-guide/create-document.md b/net/developer-guide/create-document.md index 8dfb868..84896e2 100644 --- a/net/developer-guide/create-document.md +++ b/net/developer-guide/create-document.md @@ -19,10 +19,8 @@ structuredData: name: How to create new document using the GroupDocs.Editor in C# description: Learn how to create new document using the GroupDocs.Editor in C# step by step steps: - - name: Prepare a Callback function to save the new document stream if needed - text: Callback function allow to save the new document stream - name: Invoke the appropriate Editor class constructor - text: Pass a Callback function delegate into the most appropriate overload of the constructor of GroupDocs.Editor.Editor class + text: Pass a document format into the most appropriate overload of the constructor of GroupDocs.Editor.Editor class - name: Make all necessary edits and savings text: After document is successfully loaded, you can get its metainfo, generate its editable version, and finally save it to the resultant file --- diff --git a/net/developer-guide/edit-document/_index.md b/net/developer-guide/edit-document/_index.md index 7d0b8b3..44ca34b 100644 --- a/net/developer-guide/edit-document/_index.md +++ b/net/developer-guide/edit-document/_index.md @@ -52,7 +52,7 @@ Second overload is parameterless — it chooses the most appropriate default edi ```csharp string inputFilePath = "C:\\input_path\\document.docx"; //path to some document -Editor editor = new Editor(inputFilePath, delegate { return new WordProcessingLoadOptions(); }); +Editor editor = new Editor(inputFilePath, new WordProcessingLoadOptions()); EditableDocument openedDocument = editor.Edit();//with default edit options WordProcessingEditOptions editOptions = new WordProcessingEditOptions(); @@ -66,7 +66,7 @@ There can be generated several [EditableDocument](https://reference.groupdocs.c ```csharp string inputXlsxPath = "C://input/spreadsheet.xlsx"; -Editor editor = new Editor(inputXlsxPath, delegate { return new SpreadsheetLoadOptions(); }); +Editor editor = new Editor(inputXlsxPath, new SpreadsheetLoadOptions()); SpreadsheetEditOptions editOptions1 = new SpreadsheetEditOptions(); editOptions1.WorksheetIndex = 0;//index is 0-based, so this is 1st tab diff --git a/net/developer-guide/edit-document/edit-ebook.md b/net/developer-guide/edit-document/edit-ebook.md index 21c59f0..62fbe62 100644 --- a/net/developer-guide/edit-document/edit-ebook.md +++ b/net/developer-guide/edit-document/edit-ebook.md @@ -35,11 +35,11 @@ string epubPath = "path/to/Alices Adventures in Wonderland.epub"; GroupDocs.Editor.Editor editorMobi = new Editor(mobiPath); FileStream azw3Stream = File.OpenRead(azw3Path); -GroupDocs.Editor.Editor editorAzw3 = new Editor(delegate() { return azw3Stream; }); +GroupDocs.Editor.Editor editorAzw3 = new Editor(azw3Stream); byte[] epubBytes = File.ReadAllBytes(epubPath); MemoryStream epubStream = new MemoryStream(epubBytes); -GroupDocs.Editor.Editor editorEpub = new Editor(delegate () { return epubStream; }); +GroupDocs.Editor.Editor editorEpub = new Editor(epubStream); // ... diff --git a/net/developer-guide/edit-document/edit-email.md b/net/developer-guide/edit-document/edit-email.md index 8a9bb2b..51180f3 100644 --- a/net/developer-guide/edit-document/edit-email.md +++ b/net/developer-guide/edit-document/edit-email.md @@ -56,7 +56,7 @@ string emlInputPath = System.IO.Path.Combine(Common.TestHelper.EmailFolder, emlF using (FileStream emlStream = File.OpenRead(emlInputPath)) using (Editor editorFromPath = new Editor(emlInputPath))//from the path -using (Editor editorFromStream = new Editor(delegate () { return emlStream; }))//from the stream +using (Editor editorFromStream = new Editor(emlStream))//from the stream { //Here two Editor instances can separately work with one file } diff --git a/net/developer-guide/edit-document/edit-excel/_index.md b/net/developer-guide/edit-document/edit-excel/_index.md index 15599f7..f5be5ad 100644 --- a/net/developer-guide/edit-document/edit-excel/_index.md +++ b/net/developer-guide/edit-document/edit-excel/_index.md @@ -56,7 +56,7 @@ Example below shows such situation: loading the password-protected spreadsheet: string inputXlsxPath = "C://input/spreadsheet.xlsx"; SpreadsheetLoadOptions loadOptions = new SpreadsheetLoadOptions(); loadOptions.Password = "password"; -Editor editor = new Editor(inputXlsxPath, delegate { return loadOptions; }); +Editor editor = new Editor(inputXlsxPath, loadOptions); ``` There can be several scenarios here: diff --git a/net/developer-guide/edit-document/edit-markdown.md b/net/developer-guide/edit-document/edit-markdown.md index 88937b2..5f9f52c 100644 --- a/net/developer-guide/edit-document/edit-markdown.md +++ b/net/developer-guide/edit-document/edit-markdown.md @@ -72,7 +72,7 @@ string inputPath = System.IO.Path.Combine("markdown folder", filename); using (FileStream content = File.OpenRead(inputPath)) { - using (Editor fromStream = new Editor(delegate () { return content; })) + using (Editor fromStream = new Editor(content) using (Editor fromPath = new Editor(inputPath)) { GroupDocs.Editor.Metadata.IDocumentInfo info = fromStream.GetDocumentInfo(null); diff --git a/net/developer-guide/edit-document/edit-pdf.md b/net/developer-guide/edit-document/edit-pdf.md index 4920b7a..9d32535 100644 --- a/net/developer-guide/edit-document/edit-pdf.md +++ b/net/developer-guide/edit-document/edit-pdf.md @@ -80,7 +80,7 @@ editOptions.EnablePagination = true;//enable pagination for per-page processing editOptions.Pages = PageRange.FromStartPageTillEnd(3);//edit not all pages, but starting from 3rd and till the end //3. Create Editor instance, load a document -GroupDocs.Editor.Editor editor = new Editor(inputPath, delegate () { return loadOptions; }); +GroupDocs.Editor.Editor editor = new Editor(inputPath, loadOptions); //4. Edit a document and generate EditableDocument GroupDocs.Editor.EditableDocument originalDoc = editor.Edit(editOptions); @@ -125,7 +125,7 @@ string inputPdfPath = System.IO.Path.Combine(Common.TestHelper.PdfFolder, "NET_F Editor editor1 = new Editor(inputPdfPath); //Loading a PDF with PDF load options -Editor editor2 = new Editor(inputPdfPath, delegate () { return loadOptions; }); +Editor editor2 = new Editor(inputPdfPath, loadOptions); ``` ## Editing diff --git a/net/developer-guide/edit-document/edit-powerpoint/_index.md b/net/developer-guide/edit-document/edit-powerpoint/_index.md index 1d301bb..aa9d3cc 100644 --- a/net/developer-guide/edit-document/edit-powerpoint/_index.md +++ b/net/developer-guide/edit-document/edit-powerpoint/_index.md @@ -59,7 +59,7 @@ Below is an example of loading a presentation document from file path with load string inputPptxPath = "C://input/presentation.pptx"; PresentationLoadOptions loadOptions = new PresentationLoadOptions(); loadOptions.Password = "password"; -Editor editor = new Editor(inputPptxPath, delegate { return loadOptions; }); +Editor editor = new Editor(inputPptxPath, loadOptions); ``` ## Edit PowerPoint presentation diff --git a/net/developer-guide/edit-document/edit-word/_index.md b/net/developer-guide/edit-document/edit-word/_index.md index 5f92397..df5994b 100644 --- a/net/developer-guide/edit-document/edit-word/_index.md +++ b/net/developer-guide/edit-document/edit-word/_index.md @@ -62,12 +62,12 @@ loadOptions.Password = "some_password_to_open_a_document"; Please note that if document has no protection, the password will be ignored. However, if document is protected, but user has not specified a password, a [PasswordRequiredException](https://reference.groupdocs.com/editor/net/groupdocs.editor/passwordrequiredexception) will be thrown during document editing. -Next step is to load the document from stream into the [Editor](https://reference.groupdocs.com/editor/net/groupdocs.editor/editor) class. For loading documents from streams (implementations of a `System.IO.Stream`) the [`Editor` class](https://reference.groupdocs.com/editor/net/groupdocs.editor/editor) uses delegates. In other words, you need to pass the delegate instance, that points to the method, that returns a stream.  -Same with load options — they are passed via delegate. +Next step is to load the document from stream into the [Editor](https://reference.groupdocs.com/editor/net/groupdocs.editor/editor) class. For loading documents  uses streams (implementations of a `System.IO.Stream`) in the [`Editor` class](https://reference.groupdocs.com/editor/net/groupdocs.editor/editor). +Same with load options — they should be passed. ```csharp FileStream inputStream = File.OpenRead("C:\\input_path\\document.docx"); -Editor editor = new Editor(delegate { return inputStream; }, delegate { return loadOptions; }); +Editor editor = new Editor(inputStream, loadOptions); ``` ## Edit the document diff --git a/net/developer-guide/edit-document/edit-xml.md b/net/developer-guide/edit-document/edit-xml.md index 3e1c306..de4235f 100644 --- a/net/developer-guide/edit-document/edit-xml.md +++ b/net/developer-guide/edit-document/edit-xml.md @@ -33,7 +33,7 @@ string xmlInputPath = System.IO.Path.Combine("full_folder_path", xmlFilename); using (FileStream xmlStream = System.IO.File.OpenRead(xmlInputPath)) using (GroupDocs.Editor.Editor editorFromPath = new Editor(xmlInputPath))//from the path -using (GroupDocs.Editor.Editor editorFromStream = new Editor(delegate () { return xmlStream; }))//from the stream +using (GroupDocs.Editor.Editor editorFromStream = new Editor(xmlStream))//from the stream { //Here two Editor instances can separately work with one file } diff --git a/net/developer-guide/editabledocument/get-html-markup-in-different-forms.md b/net/developer-guide/editabledocument/get-html-markup-in-different-forms.md index 83aeb43..dbf0b3d 100644 --- a/net/developer-guide/editabledocument/get-html-markup-in-different-forms.md +++ b/net/developer-guide/editabledocument/get-html-markup-in-different-forms.md @@ -20,7 +20,7 @@ First of all user needs to load document into [Editor](https://reference.groupd ```csharp string inputFilePath = "C:\\input_path\\document.docx"; //path to some document WordProcessingLoadOptions loadOptions = new WordProcessingLoadOptions(); -Editor editor = new Editor(inputFilePath, delegate { return loadOptions; }); //passing path and load options (via delegate) to the constructor +Editor editor = new Editor(inputFilePath, loadOptions); //passing path and load options to the constructor EditableDocument document = editor.Edit(new WordProcessingEditOptions()); //opening document for editing with format-specific edit options ``` diff --git a/net/developer-guide/editabledocument/save-html-to-folder.md b/net/developer-guide/editabledocument/save-html-to-folder.md index 3725581..a9cb46b 100644 --- a/net/developer-guide/editabledocument/save-html-to-folder.md +++ b/net/developer-guide/editabledocument/save-html-to-folder.md @@ -15,13 +15,13 @@ Almost all HTML WYSIWYG client-side editors are able to open HTML document from ```csharp string inputFilePath = "C:\\input_path\\document.docx"; //path to some document WordProcessingLoadOptions loadOptions = new WordProcessingLoadOptions(); -Editor editor = new Editor(inputFilePath, delegate { return loadOptions; }); //passing path and load options (via delegate) to the constructor +Editor editor = new Editor(inputFilePath, loadOptions); //passing path and load options to the constructor EditableDocument document = editor.Edit(new WordProcessingEditOptions()); string outputHtmlFilePath = "C:\\output_path\\document.html"; //path to output HTML document document.Save(outputHtmlFilePath); ``` -In this example we load input WordProcessing (DOCX) document to Editor class with load options, specific for this document family type - [WordProcessingLoadOptions](https://reference.groupdocs.com/editor/net/groupdocs.editor.options/wordprocessingloadoptions). Load options are passed via delegate. Then document is converted to the [EditableDocument](https://reference.groupdocs.com/editor/net/groupdocs.editor/editabledocument) using the [Edit()](https://reference.groupdocs.com/editor/net/groupdocs.editor/editor/edit) method, which, in turn, obtains document-specific [WordProcessingEditOptions](https://reference.groupdocs.com/editor/net/groupdocs.editor.options/wordprocessingeditoptions). In the last line content is saved to the HTML file on disk, that is specified by absolute path. Please note that GroupDocs.Editor will create accompanying folder with resources automatically in the same directory, where HTML file is saved. There is another overload of the [Save()](https://reference.groupdocs.com/editor/net/groupdocs.editor/editabledocument/save) method, that obtains 2 parameters: path to HTML file and path to existing folder, where resources should be saved. For example, last 2 lines can be rewritten in the next way: +In this example we load input WordProcessing (DOCX) document to Editor class with load options, specific for this document family type - [WordProcessingLoadOptions](https://reference.groupdocs.com/editor/net/groupdocs.editor.options/wordprocessingloadoptions). Load options are passed. Then document is converted to the [EditableDocument](https://reference.groupdocs.com/editor/net/groupdocs.editor/editabledocument) using the [Edit()](https://reference.groupdocs.com/editor/net/groupdocs.editor/editor/edit) method, which, in turn, obtains document-specific [WordProcessingEditOptions](https://reference.groupdocs.com/editor/net/groupdocs.editor.options/wordprocessingeditoptions). In the last line content is saved to the HTML file on disk, that is specified by absolute path. Please note that GroupDocs.Editor will create accompanying folder with resources automatically in the same directory, where HTML file is saved. There is another overload of the [Save()](https://reference.groupdocs.com/editor/net/groupdocs.editor/editabledocument/save) method, that obtains 2 parameters: path to HTML file and path to existing folder, where resources should be saved. For example, last 2 lines can be rewritten in the next way: ```csharp string outputHtmlFilePath = "C:\\output_path\\document.html"; //path to output HTML document diff --git a/net/developer-guide/editabledocument/working-with-resources.md b/net/developer-guide/editabledocument/working-with-resources.md index 2fda782..507a6c4 100644 --- a/net/developer-guide/editabledocument/working-with-resources.md +++ b/net/developer-guide/editabledocument/working-with-resources.md @@ -28,7 +28,7 @@ Let's prepare an [EditableDocument](https://reference.groupdocs.com/editor/net/ ```csharp string inputDocxPath = "C://input/document.docx"; -Editor editor = new Editor(inputDocxPath, delegate { return new WordProcessingLoadOptions(); }); +Editor editor = new Editor(inputDocxPath, new WordProcessingLoadOptions()); WordProcessingEditOptions editOptions = new WordProcessingEditOptions(); editOptions.FontExtraction = FontExtractionOptions.ExtractAll;// Enable max font extraction - ExtractAll EditableDocument beforeEdit = editor.Edit(editOptions);// Create EditableDocument instance diff --git a/net/developer-guide/form-field-management/edit-and-update-form-fields.md b/net/developer-guide/form-field-management/edit-and-update-form-fields.md index 3f1f91b..41f2269 100644 --- a/net/developer-guide/form-field-management/edit-and-update-form-fields.md +++ b/net/developer-guide/form-field-management/edit-and-update-form-fields.md @@ -39,7 +39,7 @@ This article demonstrates how to edit form fields in a Word document using Group Use the `Editor` class to load the document with the specified load options. ```csharp - using (Editor editor = new Editor(delegate { return fs; }, delegate { return loadOptions; })) + using (Editor editor = new Editor(fs, loadOptions)) { // Further code will be placed here } @@ -118,7 +118,7 @@ internal static class EditFormFieldCollection // 3.2. ...but, because the document is unprotected, this password will be ignored // 4. Load the document with options into the Editor instance - using (Editor editor = new Editor(delegate { return fs; }, delegate { return loadOptions; })) + using (Editor editor = new Editor(fs, loadOptions)) { // 4.1. Read the FormFieldManager instance FormFieldManager fieldManager = editor.FormFieldManager; diff --git a/net/developer-guide/form-field-management/fixing-invalid-form-fields.md b/net/developer-guide/form-field-management/fixing-invalid-form-fields.md index f5d07b7..7f0582c 100644 --- a/net/developer-guide/form-field-management/fixing-invalid-form-fields.md +++ b/net/developer-guide/form-field-management/fixing-invalid-form-fields.md @@ -39,7 +39,7 @@ This article demonstrates how to fix invalid form fields in a Word document usin Use the `Editor` class to load the document with the specified load options. ```csharp - using (Editor editor = new Editor(delegate { return fs; }, delegate { return loadOptions; })) + using (Editor editor = new Editor(fs, loadOptions)) { // Further code will be placed here } @@ -127,7 +127,7 @@ internal static class FixInvalidFormFieldCollectionAndSave // 3.2. ...but, because the document is unprotected, this password will be ignored // 4. Load the document with options into the Editor instance - using (Editor editor = new Editor(delegate { return fs; }, delegate { return loadOptions; })) + using (Editor editor = new Editor(fs, loadOptions)) { // 4.1. Read the FormFieldManager instance FormFieldManager fieldManager = editor.FormFieldManager; diff --git a/net/developer-guide/form-field-management/working-with-form-fields.md b/net/developer-guide/form-field-management/working-with-form-fields.md index 0be9eb1..652650d 100644 --- a/net/developer-guide/form-field-management/working-with-form-fields.md +++ b/net/developer-guide/form-field-management/working-with-form-fields.md @@ -43,7 +43,7 @@ This article demonstrates how to load, edit, and read form fields in a Word docu Use the `Editor` class to load the document with the specified load options. ```csharp - using (Editor editor = new Editor(delegate { return fs; }, delegate { return loadOptions; })) + using (Editor editor = new Editor(fs, loadOptions)) { // Further code will be placed here } @@ -118,7 +118,7 @@ internal static class LegacyFormFieldCollection // 3.2. ...but, because the document is unprotected, this password will be ignored // 4. Load the document with options to the Editor instance - using (Editor editor = new Editor(delegate { return fs; }, delegate { return loadOptions; })) + using (Editor editor = new Editor(fs, loadOptions)) { // 4.1. Read the FormFieldManager instance FormFieldManager fieldManager = editor.FormFieldManager; diff --git a/net/developer-guide/load-document.md b/net/developer-guide/load-document.md index e6c1516..14d22c1 100644 --- a/net/developer-guide/load-document.md +++ b/net/developer-guide/load-document.md @@ -22,63 +22,80 @@ structuredData: - name: Prepare a LoadOptions instance if needed text: If input document is password-protected or requires some adjusting using load, or it is required to specify its format family explicitly, create an appropriate inheritor of the ILoadOptions interface - name: Invoke the appropriate Editor class constructor - text: Pass a filepath as a string or a byte stream through delegate into the most appropriate overload of the constructor of GroupDocs.Editor.Editor class + text: Pass a filepath as a string or a byte stream into the most appropriate overload of the constructor of GroupDocs.Editor.Editor class - name: Make all necessary edits and savings text: After document is successfully loaded, you can get its metainfo, generate its editable version, and finally save it to the resultant file --- -> This article describes how to load input document to the [**GroupDocs.Editor**](https://products.groupdocs.com/editor/net) and how to apply load options. +> The text provides a comprehensive guide on how to load documents using the GroupDocs.Editor for .NET API. Below is a revised version that improves readability, consistency, and clarity. -First of all the input document, which should be accessible as a byte stream or through valid file path, should be loaded into the GroupDocs.Editor by creating an instance of the [Editor](https://reference.groupdocs.com/editor/net/groupdocs.editor/editor) class through one of the constructor overloads.  -If the input document is presented as a stream, it should be loaded through delegate. Source code below shows two ways of loading documents: from path and from stream. +--- + +### Load Document + +This guide explains how to load a document from a local disk or file stream for editing using the GroupDocs.Editor for .NET API. + +#### Introduction + +In this article, you will learn how to load an input document into [**GroupDocs.Editor**](https://products.groupdocs.com/editor/net) and apply load options. + +### Loading Documents + +To load an input document, which should be accessible either as a byte stream or through a valid file path, you can create an instance of the [Editor](https://reference.groupdocs.com/editor/net/groupdocs.editor/editor) class using one of its constructor overloads. Below are examples of loading documents from a file path and from a stream. ```csharp -//through path -string inputFilePath = "C:\\input_path\\document.docx"; //path to some document +// Load document from file path +string inputFilePath = "C:\\input_path\\document.docx"; // Path to the document Editor editor = new Editor(inputFilePath); -//through stream +// Load document from stream FileStream inputStream = System.IO.File.OpenRead(inputFilePath); -Editor editor = new Editor(delegate { return inputStream; }); +Editor editor = new Editor(inputStream); ``` -When two overloads from example above are used, GroupDocs.Editor automatically detects the format of input document and applies the most appropriate default loading options for the input document.  -However, it is possible and even recommended to specify correct loading options explicitly using constructor overloads, which accept two parameters. Like streams, loading options should be specified through delegates.  -Source code below shows using such options. +When using the constructor overloads shown above, GroupDocs.Editor automatically detects the format of the input document and applies the most suitable default loading options. However, it is recommended to specify the correct loading options explicitly by using constructor overloads that accept two parameters. Here is how you can do this: ```csharp -//through path -string inputFilePath = "C:\\input_path\\document.docx"; //path to some document +// Load document from file path with load options +string inputFilePath = "C:\\input_path\\document.docx"; // Path to the document WordProcessingLoadOptions wordLoadOptions = new WordProcessingLoadOptions(); -Editor editor = new Editor(inputFilePath, delegate { return wordLoadOptions; }); //passing path and load options (via delegate) to the constructor +Editor editor = new Editor(inputFilePath, wordLoadOptions); // Passing path and load options to the constructor -//through stream -MemoryStream inputStream = new MemoryStream();//obtained from somewhere +// Load document from stream with load options +MemoryStream inputStream = new MemoryStream(); // Stream obtained from somewhere SpreadsheetLoadOptions spreadsheetLoadOptions = new SpreadsheetLoadOptions(); -Editor editor = new Editor(delegate { return inputStream; }, delegate { return spreadsheetLoadOptions; }); +Editor editor = new Editor(inputStream, spreadsheetLoadOptions); ``` -Please note that not all document formats have appropriate classes, that represent load options. As for version 22.7, only WordProcessing, Spreadsheet and Presentation family formats, as well as a distinct PDF format, have load options. For other document formats, such as DSV, TXT or XML, there are no load options. +### Load Options + +Please note that not all document formats have associated classes for load options. As of version 22.7, only WordProcessing, Spreadsheet, Presentation formats, and a distinct PDF format have specific load options classes. Other formats, such as DSV, TXT, or XML, do not have load options. + +| Format Family | Example Formats | Load Options Class | +|--------------------|--------------------------------------|---------------------------------------------------------------------------------------------------------| +| WordProcessing | DOC, DOCX, DOCM, DOT, ODT | [`WordProcessingLoadOptions`](https://reference.groupdocs.com/editor/net/groupdocs.editor.options/wordprocessingloadoptions) | +| Spreadsheet | XLS, XLSX, XLSM, XLSB | [`SpreadsheetLoadOptions`](https://reference.groupdocs.com/editor/net/groupdocs.editor.options/spreadsheetloadoptions) | +| Presentation | PPT, PPTX, PPS, POT | [`PresentationLoadOptions`](https://reference.groupdocs.com/editor/net/groupdocs.editor.options/presentationloadoptions) | +| Fixed-layout format| PDF | [`PdfLoadOptions`](https://reference.groupdocs.com/editor/net/groupdocs.editor.options/pdfloadoptions) | -| Format family | Example formats | Load options class | -| --- | --- | --- | -| WordProcessing | DOC, DOCX, DOCM, DOT, ODT | [`WordProcessingLoadOptions`](https://reference.groupdocs.com/editor/net/groupdocs.editor.options/wordprocessingloadoptions) | -| Spreadsheet | XLS, XLSX, XLSM, XLSB | [`SpreadsheetLoadOptions`](https://reference.groupdocs.com/editor/net/groupdocs.editor.options/spreadsheetloadoptions) | -| Presentation | PPT, PPTX, PPS, POT | [`PresentationLoadOptions`](https://reference.groupdocs.com/editor/net/groupdocs.editor.options/presentationloadoptions) | -| Fixed-layout format | PDF | [`PdfLoadOptions`](https://reference.groupdocs.com/editor/net/groupdocs.editor.options/pdfloadoptions) | +### Handling Password-Protected Documents -Using load options is the only way for working with password-protected input documents. Any document can be loaded into the [`Editor`](https://reference.groupdocs.com/editor/net/groupdocs.editor/editor) instance, even encoded document without the password. However, on the next step — opening for editing, — the exception will be thrown. GroupDocs.Editor handles passwords and encoded documents in the next way: +Using load options is essential when working with password-protected documents. Any document can be loaded into the [`Editor`](https://reference.groupdocs.com/editor/net/groupdocs.editor/editor) instance, even if it is password-protected. However, if the password is not handled correctly, an exception will be thrown during the editing process. Here’s how GroupDocs.Editor handles passwords: -1. If document is not encoded, password is ignored anyway, whether or not it was specified. -2. If document is password-protected, but password is not specified, the [`PasswordRequiredException`](https://reference.groupdocs.com/editor/net/groupdocs.editor/passwordrequiredexception) will be thrown later during editing. -3. If document is password-protected, and password is specified, but is incorrect, the [`IncorrectPasswordException`](https://reference.groupdocs.com/editor/net/groupdocs.editor/incorrectpasswordexception) will be thrown later during editing. +1. If the document is not password-protected, any specified password will be ignored. +2. If the document is password-protected but no password is specified, a [`PasswordRequiredException`](https://reference.groupdocs.com/editor/net/groupdocs.editor/passwordrequiredexception) will be thrown during editing. +3. If the document is password-protected and an incorrect password is provided, an [`IncorrectPasswordException`](https://reference.groupdocs.com/editor/net/groupdocs.editor/incorrectpasswordexception) will be thrown during editing. -Example below shows specifying password for opening some password-protected WordProcessing document. +The example below demonstrates how to specify a password for opening a password-protected WordProcessing document: ```csharp Stream inputStream = GetDocumentStreamFromSomewhere(); WordProcessingLoadOptions wordLoadOptions = new WordProcessingLoadOptions(); wordLoadOptions.Password = "correct_password"; -Editor editor = new Editor(inputFilePath, delegate { return wordLoadOptions; }); +Editor editor = new Editor(inputFilePath, wordLoadOptions); ``` -{{< alert style="info" >}}Same approach is applicable for Spreadsheet, Presentation, and PDF documents too.{{< /alert >}} +{{< alert style="info" >}}The same approach applies to Spreadsheet, Presentation, and PDF documents as well.{{< /alert >}} + +--- + +This revision enhances clarity, improves structure, and ensures that the instructions are easy to follow. \ No newline at end of file diff --git a/net/developer-guide/working-with-mobi-documents.md b/net/developer-guide/working-with-mobi-documents.md index 85b4166..18f4088 100644 --- a/net/developer-guide/working-with-mobi-documents.md +++ b/net/developer-guide/working-with-mobi-documents.md @@ -28,7 +28,7 @@ string inputMobiPath = "C://input/book.mobi"; Editor editorFromPath = new Editor(inputMobiPath); FileStream inputMobiStream = File.OpenRead("C://input/book.mobi"); -Editor editorFromStream = new Editor(delegate() { return inputMobiStream; }); +Editor editorFromStream = new Editor(inputMobiStream); ``` There is no loading options, because Mobi has nothing to tune-up during loading, — it cannot have a password protection, and can be processed only in one way.