English

Experience Powerful Document Editing for PDF and Office Files

Our .NET and Java APIs let you use the HTML editor of your choice to seamlessly edit PDF, DOCX, XLSX, PPTX, ODT, XPS, TXT, RTF, HTML, and many more file types by building high-performance, feature-rich document editing apps.

Try our APIs for FreeGet Temporary License

Edit PDF, Word documents, Spreadsheets, Presentations, and More Files with Platform-Independent APIs

Modifying a document's text, graphics, and other elements is commonly referred to as document editing. It could have multiple uses, such as optimizing the accuracy and clarity of content, improving document readability, and many more. The importance of electronic document editors has increased with the ever-growing usage and sharing of digitally processed documents.

For anyone working as a document editor, being able to efficiently and accurately modify documents could help save time and effort. It would enable him to focus on other high-priority tasks in the document processing life cycle. GroupDocs.Editor APIs for .NET and Java platforms are a great option for editing PDF, Office, OpenDocument, Text, RTF, HTML, and more file formats. Using the GroupDocs APIs, you can upgrade your existing document editing software or build dynamic PDF editor or Word editor apps from scratch. You can also develop a fully functional document editor to quickly and easily edit a document in one of the supported formats.

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 and build your own powerful document editor.

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 documents and other data files

Now that you are done setting up the correct API version, let’s check some of the widely used PDF editing, Word editing, and other document editing case scenarios.

Use cases for editing PDF documents and other data files

Learn to Master PDF Document Editing 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 documents 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 documents 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 Master PDF Document Editing in Your .NET Apps

Edit PDF documents in .NET

Please use the following code to build a PDF editor that supports 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 Effortlessly Edit Word Documents, Spreadsheets, and Presentations in .NET and Java In a Few Steps?

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 Effortlessly Edit Word Documents, Spreadsheets, and Presentations in .NET and Java In a Few Steps?

Edit 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);
                }
            }
        }
    }
} 

Edit Microsoft Word Documents in Java

For creating a word editor 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.

Unlock Text Document Editing in .NET and Java: Build Your Own Text Editor Apps with Ease

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 document editor app for this purpose and enjoy a truly cross-platform document editing experience.

Unlock Text Document Editing in .NET and Java: Build Your Own Text Editor Apps with Ease

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

You can use the code below to edit text files in Java. You can then save the modified document to Text (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);  

Understanding Email Document Formats: Edit them Seamlessly in .NET and Java

Email documents 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.

Understanding Email Document Formats: Edit them Seamlessly 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.