English

Word, Excel, PowerPoint, and PDF editor for .NET and Java

Use the HTML editor of your choice for editing PDF, DOCX, XLSX, PPTX, ODT, XPS, TXT, RTF, HTML, and many other file types in .NET and Java by building feature-rich document editing apps.

Try our APIs for FreeGet Temporary License

Platform independent APIs to edit PDF, word documents, spreadsheets, presentations, and other data files

Document editing in the context of modifying your digital files refers to the process of altering the text, images, or other elements within a document. Digital editing of data files could be used to improve content accuracy and clarity, add corrections to the existing content, make the document easier to read, and much more. With the ever-increasing use of different types of digital documents, the need to electronically edit them is becoming more and more important.

The ability to electronically edit digital documents has become an essential skill for anyone who works with documents. Knowing how to edit PDF, Microsoft Office, and other data files quickly and accurately can be a great time-saver. For this purpose, you can use GroupDocs.Editor APIs that support editing an array of popular data file formats such as PDF, Word, Excel, PowerPoint, OpenDocument, RTF, Text, HTML, eBooks, and many more across .NET and Java platforms.

Getting Started

To start editing your documents in .NET or Java, you will first need to install the required version of GroupDocs.Editor. Please refer to the instructions shared in the following sections for correctly setting up GroupDocs.Editor for .NET or Java.

GroupDocs.Editor for .NET installation

Please feel free to download the DLLs or MSI installer from the downloads section, or use NuGet to install the API. You can also use the Package Manager Console:
PM> Install-Package GroupDocs.Editor 
For more help with the installation, please feel free to check this guide.

GroupDocs.Editor for Java installation

For the Java version, you can either download the JAR file from the downloads section or add the following configurations for the repository and dependency in your (Maven-based) Java apps:
<repository>
<id>GroupDocsJavaAPI</id>
    <name>GroupDocs Java API</name> 
    <url>https://repository.groupdocs.com/repo/</url>
</repository>
<dependency>
        <groupId>com.groupdocs</groupId>
            <artifactId>groupdocs-editor</artifactId>
        <version>20.11</version> 
</dependency>
Please review this installation guide if you need more information.

Use cases for editing PDF and other data files

Now that you are done setting up the correct API version, let’s check some of the widely used case scenarios for editing your multi-format documents.

Use cases for editing PDF and other data files

Learn to edit PDF documents in your .NET apps

PDF format is a popular file type used for documents, reports, and other digital content. It stands for Portable Document Format and is widely used due to its ability to produce high-quality documents that are easy to share. It is distinct from the other popular data file formats because it offers a layout that is fixed and it maintains the same formatting and layout regardless of the device and operating system you are reading or viewing it on.

But what if you need to make changes to a PDF document? Editing PDF files can be a tricky process, but it doesn’t have to be if you are using GroupDocs.Editor for .NET API. This API enables you to edit PDF files using a WYSIWYG editor like any other document. Currently, PDF editing is supported only in the .NET version of GroupDocs.Editor API and not in the Java version.

Learn to edit PDF documents in your .NET apps

PDF document editing in .NET

Please use the following code for loading, editing, and then saving a PDF file in .NET:
  //1. Simple preparations of input data
const string filename = "sample.pdf";
const string password = "password"; 
string inputPath = System.IO.Path.Combine(Common.TestHelper.PdfFolder, filename);

//2. Create a load options class with password
GroupDocs.Editor.Options.PdfLoadOptions loadOptions = new PdfLoadOptions();
loadOptions.Password = password;

//3. Create edit options and tune/adjust if necessary
GroupDocs.Editor.Options.PdfEditOptions editOptions = new PdfEditOptions();
editOptions.EnablePagination = true; //Enable pagination for per-page processing in WYSIWYG-editor
editOptions.Pages = PageRange.FromStartPageTillEnd(3); //Edit not all pages, but starting from 3rd and till the end

//4. Create an Editor instance, load a document
GroupDocs.Editor.Editor editor = new Editor(inputPath, delegate () { return loadOptions; });

//5. Edit a document and generate EditableDocument
GroupDocs.Editor.EditableDocument originalDoc = editor.Edit(editOptions);

//6. Generate HTML/CSS, send it to WYSIWYG, edit there, and obtain edited version
string originalContent = originalDoc.GetEmbeddedHtml();
string editedContent = originalContent.Replace(".NET Framework", "I love Java!!!");

//7. Generate EditableDocument from edited content
EditableDocument editedDoc = EditableDocument.FromMarkup(editedContent, null);

//8. Create and adjust save options
GroupDocs.Editor.Options.PdfSaveOptions saveOptions = new PdfSaveOptions();
saveOptions.Compliance = PdfCompliance.Pdf20;

//9. Save to a file or a stream
string outputPath = System.IO.Path.Combine(Common.TestHelper.OutputFolder, filename);
editor.Save(editedDoc, outputPath, saveOptions);

//10. Don't forget to dispose all resources
originalDoc.Dispose();
editedDoc.Dispose();
editor.Dispose(); 

How to edit word-processing documents, spreadsheets, and presentations in .NET and Java?

Microsoft Word, Excel, and PowerPoint are widely used formats for creating documents, spreadsheets, and presentations respectively. They are used as the standard formats in most businesses and organizations and are essential tools for anyone looking to organize, analyze, and present data in an efficient manner.

Are you looking to programmatically edit any of these document formats in .NET or Java? If yes, you can use GroupDocs.Editor APIs and edit Microsoft Word, Excel, and PowerPoint documents and you wouldn’t even be needing Microsoft Office installed on your system to do this.

How to edit word-processing documents, spreadsheets, and presentations in .NET and Java?

Editing Word documents in your .NET apps

To edit word documents (DOCX) in .NET, please use this code:
    using (FileStream fs = File.OpenRead("filepath/document.docx"))
{   
    // Load Document
    Options.WordProcessingLoadOptions loadOptions = new WordProcessingLoadOptions();
    loadOptions.Password = "password-if-any";
    // Edit Document
    using (Editor editor = new Editor(delegate { return fs; }, delegate { return loadOptions; }))
    {
        Options.WordProcessingEditOptions editOptions = new WordProcessingEditOptions();
        editOptions.FontExtraction = FontExtractionOptions.ExtractEmbeddedWithoutSystem;
        editOptions.EnableLanguageInformation = true;
        editOptions.EnablePagination = true;

        using (EditableDocument beforeEdit = editor.Edit(editOptions))
        {
            string originalContent = beforeEdit.GetContent();
            List allResources = beforeEdit.AllResources;

            string editedContent = originalContent.Replace("document", "edited document");
            // Save Document
            using (EditableDocument afterEdit = EditableDocument.FromMarkup(editedContent, allResources))
            {
                WordProcessingFormats docxFormat = WordProcessingFormats.Docx;
                Options.WordProcessingSaveOptions saveOptions = new WordProcessingSaveOptions(docxFormat);
                            
                saveOptions.EnablePagination = true;
                saveOptions.Locale = System.Globalization.CultureInfo.GetCultureInfo("en-US");
                saveOptions.OptimizeMemoryUsage = true;
                saveOptions.Password = "password";
                saveOptions.Protection = new WordProcessingProtection(WordProcessingProtectionType.ReadOnly, "write_password");

                using (FileStream outputStream = File.Create("filepath/editedDocument.docx"))
                {
                    editor.Save(afterEdit, outputStream, saveOptions);
                }
            }
        }
    }
} 

Modify Microsoft Word files in Java

For editing Word documents in Java, please use the following code:
    // Edit the Word DOC/DOCX documents in Java
Options.WordProcessingLoadOptions loadOptions = new WordProcessingLoadOptions();
loadOptions.setPassword("password-if-any");

Editor editor = new Editor("path/document.docx", loadOptions);
EditableDocument defaultWordProcessingDoc = editor.edit();

// Either edit using any WYSIWYG editor or edit programmatically
String allEmbeddedInsideString = defaultWordProcessingDoc.getEmbeddedHtml();
String allEmbeddedInsideStringEdited = allEmbeddedInsideString.replace("document", "edited document");

// Save the edited document
EditableDocument editedDoc = EditableDocument.fromMarkup(allEmbeddedInsideStringEdited, null);
WordProcessingSaveOptions saveOptions = new WordProcessingSaveOptions(WordProcessingFormats.Docx);
editor.save(editedDoc, "path/edited-document.docx", saveOptions); 

Editing Excel spreadsheets in .NET

You can edit Excel documents in .NET using the following C# code:
Options.SpreadsheetLoadOptions loadOptions = new SpreadsheetLoadOptions();
loadOptions.Password = "password";

// Load the Spreadsheet
Editor editor = new Editor("path/spreadsheet.xlsx", delegate { return loadOptions; });

// Get 1st tab of the Spreadsheet
SpreadsheetEditOptions sheetTab1EditOptions = new SpreadsheetEditOptions();
sheetTab1EditOptions.WorksheetIndex = 0; // first worksheet

// Obtain HTML markup from some EditableDocument instance
EditableDocument firstTab = editor.Edit(sheetTab1EditOptions);
string bodyContent = firstTab.GetBodyContent(); // HTML markup from inside the HTML -> BODY element
string allContent = firstTab.GetContent();      // Full HTML markup of all document, with HTML -> HEAD header and all its content

List onlyImages = firstTab.Images;
List allResourcesTogether = firstTab.AllResources;

string editedContent = allContent.Replace("Company Name", "New Company Name");
EditableDocument afterEdit = EditableDocument.FromMarkup(editedContent, allResourcesTogether);
// Create save options
SpreadsheetFormats xlsxFormat = SpreadsheetFormats.Xlsx;
Options.SpreadsheetSaveOptions saveOptions = new SpreadsheetSaveOptions(SpreadsheetFormats.Xlsx);

// Set new opening password
saveOptions.Password = "newPassword";
saveOptions.WorksheetProtection = new WorksheetProtection(WorksheetProtectionType.All, "WriteProtectionPassword");

// Create output stream
using (FileStream outputStream = File.Create("path/editedSpreadsheet.xlsx"))
{
    editor.Save(afterEdit, outputStream, saveOptions);
} 

Edit Microsoft Excel documents in Java

To edit Excel spreadsheets in Java, you can use this code snippet:
// Edit the Excel XLS/XLSX documents in Java
SpreadsheetLoadOptions loadOptions = new SpreadsheetLoadOptions();
loadOptions.setPassword("password-if-any");

// Loading Spreadsheet
Editor editor = new Editor("path/sample_sheet.xlsx", loadOptions);

// Edit 1st tab of the Spreadsheet
SpreadsheetEditOptions editOptions = new SpreadsheetEditOptions();
editOptions.setWorksheetIndex(0); // index is 0-based, so this is 1st tab
EditableDocument firstTab = editor.edit(editOptions);

String bodyContent = firstTab.getBodyContent();
String allContent = firstTab.getContent();
List onlyImages = firstTab.getImages();
List allResourcesTogether = firstTab.getAllResources();

String editedSheetContent = allContent.replace("Old Company Name","New Company Name");
EditableDocument editedDoc = EditableDocument.fromMarkup(editedSheetContent, null);

SpreadsheetSaveOptions saveOptions = new SpreadsheetSaveOptions(SpreadsheetFormats.Xlsx);
saveOptions.setPassword("new-password");
editor.save(editedDoc, "path/edited_spreadsheet.xlsx", saveOptions);
firstTab.dispose();
editor.dispose()

Similarly, you can edit PowerPoint presentations too using GroupDocs.Editor API. Please check the .NET and Java editing guides for more help.

Learn to edit text documents in .NET and Java and build your own text editor apps

Text files (denoted by TXT) are one of the most commonly used file formats, as they are lightweight, simple, and easy to create and share. They are used in a variety of ways, from writing code to creating plain, text-only documents. Text documents do not contain any text formatting, images, forms, tables, or any other rich-text elements.

GroupDocs.Editor APIs support editing text files in .NET and Java platforms. You may integrate text document editing features into your existing application and enhance its capabilities or build your own text editor app for this purpose.

Learn to edit text documents in .NET and Java and build your own text editor apps

Edit text documents in the .NET platform

The below-given sample code can be used to edit text files in .NET. The edited file could be saved in TXT and word-processing (DOCM) formats:
//Load the text file
string inputTxtPath = "C://input/file.txt";
Editor editor = new Editor(inputTxtPath);

TextEditOptions editOptions = new TextEditOptions();
editOptions.Encoding = System.Text.Encoding.UTF8;
editOptions.RecognizeLists = true;
editOptions.LeadingSpaces = TextLeadingSpacesOptions.ConvertToIndent;
editOptions.TrailingSpaces = TextTrailingSpacesOptions.Trim;
editOptions.Direction = TextDirection.Auto;

EditableDocument beforeEdit = editor.Edit(editOptions); // Create EditableDocument instance

string originalTextContent = beforeEdit.GetContent(); // Get HTML content
string updatedTextContent = originalTextContent.Replace("text", "EDITED text"); // Edit the content
List allResources = beforeEdit.AllResources; // Get resources (only one stylesheet in this case)

//Finally, create new EditableDocument
EditableDocument afterEdit = EditableDocument.FromMarkup(updatedTextContent, allResources);\
//Save the edited document to TXT and DOCM format
TextSaveOptions txtSaveOptions = new TextSaveOptions();
txtSaveOptions.AddBidiMarks = true;
txtSaveOptions.PreserveTableLayout = true;

WordProcessingSaveOptions wordSaveOptions = new WordProcessingSaveOptions(WordProcessingFormats.Docm);

string outputTxtPath = "C:\output\document.txt";
string outputWordPath = "C:\output\document.docm";

editor.Save(afterEdit, outputTxtPath, txtSaveOptions);
editor.Save(afterEdit, outputWordPath, wordSaveOptions); 

Editing text documents (TXT) in Java

To edit text files in Java, you can use the code shown below. You can then save the modified document to TXT or Word (DOCM) file formats:
// Loading the text document
String inputTxtPath = "C://input//file.txt";
Editor editor = new Editor(inputTxtPath);

TextEditOptions editOptions = new TextEditOptions();
editOptions.setEncoding(StandardCharsets.UTF_8);
editOptions.setRecognizeLists(true);
editOptions.setLeadingSpaces(TextLeadingSpacesOptions.ConvertToIndent);
editOptions.setTrailingSpaces(TextTrailingSpacesOptions.Trim);
editOptions.setDirection(TextDirection.Auto);

EditableDocument beforeEdit = editor.edit(editOptions); // Create EditableDocument instance

String originalTextContent = beforeEdit.getContent(); // Get HTML content
String updatedTextContent = originalTextContent.replace("text", "EDITED text"); // Edit the content
List allResources = beforeEdit.getAllResources(); // Get resources (only one stylesheet actually in this case)

//Finally, create new EditableDocument
EditableDocument afterEdit = EditableDocument.fromMarkup(updatedTextContent, allResources);
//Saving the modified file to TXT and DOCM formats
TextSaveOptions txtSaveOptions = new TextSaveOptions();
txtSaveOptions.setAddBidiMarks(true);
txtSaveOptions.setPreserveTableLayout(true);

WordProcessingSaveOptions wordSaveOptions = new WordProcessingSaveOptions(WordProcessingFormats.Docm);

String outputTxtPath = "C:\\output\\document.txt";
String outputWordPath = "C:\\output\\document.docm";

editor.save(afterEdit, outputTxtPath, txtSaveOptions);
editor.save(afterEdit, outputWordPath, wordSaveOptions);  

What are the email document formats and how can you edit them in .NET and Java?

Email documents are files that contain the content of an email message, including the message body and any attachments. These files are typically used for transferring email messages between different email clients or for storing them in a standard format. They are used by various email clients such as Microsoft Outlook, Apple Mail, and Mozilla Thunderbird. These documents form an integral part of how we communicate with each other in the digital age.

With the increase in the use of these file types, editing them is also becoming common. Automating the editing process can be invaluable whether you wish to integrate the process with another system, or incorporate custom logic. GroupDocs.Editor APIs (for .NET and Java) enable you to do just that. You can edit email documents of popular formats using these APIs.

What are the email document formats and how can you edit them in .NET and Java?

How to edit email documents in .NET?

If you are looking to load, edit, and save an email message (MSG), please use this C# code:
//1. Prepare a sample file
const string msgFilename = "ComplexExample.msg";
string msgInputPath = System.IO.Path.Combine(Common.TestHelper.EmailFolder, msgFilename);

//2. Load to the Editor class
Editor msgEditor = new Editor(msgInputPath);

//3. Create edit options with all content
Options.EmailEditOptions editOptions = new EmailEditOptions(MailMessageOutput.All);

//4. Generate an editable document
EditableDocument originalDoc = msgEditor.Edit(editOptions);

//5. Emit HTML from EditableDocument, send it to the client-side, edit it there in WYSIWYG-editor (omitted here)
string savedHtmlContent = originalDoc.GetEmbeddedHtml();

//6. Obtain edited content from the client-side and generate a new EditableDocument from it (omitted here)
EditableDocument editedDoc = EditableDocument.FromMarkup(savedHtmlContent, null);

//7. Create 1st save options
EmailSaveOptions saveOptions1 = new EmailSaveOptions(MailMessageOutput.Common);

//8. Create 2nd save options
EmailSaveOptions saveOptions2 = new EmailSaveOptions(MailMessageOutput.Body | MailMessageOutput.Attachments);

//9. Generate and save 1st output MSG to the file
string outputMsgPath = System.IO.Path.Combine(Common.TestHelper.OutputFolder, "OutputFile.msg");
msgEditor.Save(editedDoc, outputMsgPath, saveOptions1);

//10. Generate and save 2nd output MSG to the stream
Stream outputMsgStream = File.Create(Path.Combine(Common.TestHelper.OutputFolder, "OutputStream.msg"));
msgEditor.Save(editedDoc, outputMsgStream, saveOptions2);

//11. Dispose all resources
outputMsgStream.Dispose();
editedDoc.Dispose();
originalDoc.Dispose();
msgEditor.Dispose(); 

Email document editing in Java

For loading, editing, and saving an email message file (MSG), you can use the following code:
//1. Prepare a sample file
String msgInputPath = "C:\ComplexExample.msg";

//2. Load to the Editor class
Editor msgEditor = new Editor(msgInputPath);

//3. Create edit options with all content
EmailEditOptions editOptions = new EmailEditOptions(MailMessageOutput.All);

//4. Generate an editable document
EditableDocument originalDoc = msgEditor.edit(editOptions);

//5. Emit HTML from EditableDocument, send it to the client-side, edit it there in WYSIWYG-editor (omitted here)
String savedHtmlContent = originalDoc.getEmbeddedHtml();

//6. Obtain edited content from the client-side and generate a new EditableDocument from it (omitted here)
EditableDocument editedDoc = EditableDocument.fromMarkup(savedHtmlContent, null);

//7. Create 1st save options
EmailSaveOptions saveOptions1 = new EmailSaveOptions(MailMessageOutput.Common);

//8. Create 2nd save options
EmailSaveOptions saveOptions2 = new EmailSaveOptions(MailMessageOutput.Body | MailMessageOutput.Attachments);

//9. Generate and save 1st output MSG to the file
String outputMsgPath = "C:\OutputFile.msg";
msgEditor.save(editedDoc, outputMsgPath, saveOptions1);

//10. Generate and save 2nd output MSG to the stream
Stream outputMsgStream = "C:\OutputStream.msg";
msgEditor.save(editedDoc, outputMsgStream, saveOptions2);

//11. Dispose all resources
outputMsgStream.dispose();
editedDoc.dispose();
originalDoc.dispose();
msgEditor.dispose(); 

You can also edit a PDF, DOCX, XLSX, PPTX, ODT, ODS, RTF, TXT, CSV, XML, EPUB, and many other documents on the fly using our Free Document Editing Apps from a device of your choice so, please feel free to check them out.

Looking for help?

Checkout our support channels for help with your questions related to Conholdate product API features and working.