Die Dokumentenbearbeitung im Zusammenhang mit der Änderung Ihrer digitalen Dateien bezieht sich auf den Prozess der Änderung von Text, Bildern oder anderen Elementen in einem Dokument. Die digitale Bearbeitung von Datendateien könnte verwendet werden, um die Genauigkeit und Klarheit des Inhalts zu verbessern, Korrekturen an den vorhandenen Inhalten hinzuzufügen, das Dokument leichter lesbar zu machen und vieles mehr. Mit der ständig zunehmenden Verwendung verschiedener Arten von digitalen Dokumenten wird die Notwendigkeit, diese elektronisch zu bearbeiten, immer wichtiger.
Die Fähigkeit, digitale Dokumente elektronisch zu bearbeiten, ist zu einer wesentlichen Fähigkeit für jeden geworden, der mit Dokumenten arbeitet. Zu wissen, wie man PDF-, Microsoft Office- und andere Datendateien schnell und genau bearbeitet, kann viel Zeit sparen. Zu diesem Zweck können Sie GroupDocs.Editor-APIs verwenden, die die Bearbeitung einer Reihe gängiger Datendateiformate wie PDF, Word, Excel, PowerPoint, OpenDocument, RTF, Text, HTML, eBooks und viele mehr auf .NET- und Java-Plattformen unterstützen .
Um mit der Bearbeitung Ihrer Dokumente in .NET oder Java zu beginnen, müssen Sie zunächst die erforderliche Version von GroupDocs.Editor installieren. Bitte beachten Sie die Anweisungen in den folgenden Abschnitten zur korrekten Einrichtung von GroupDocs.Editor für .NET oder Java.
Bitte zögern Sie nicht, die DLLs oder das MSI-Installationsprogramm aus dem Download-Bereich herunterzuladen, oder verwenden Sie NuGet, um die API zu installieren. Sie können auch die Paket-Manager-Konsole verwenden:
Weitere Hilfe bei der Installation finden Sie in diesem Handbuch.
Für die Java-Version können Sie entweder die JAR-Datei aus dem Download-Bereich herunterladen oder die folgenden Konfigurationen für das Repository und hinzufügen Abhängigkeit in Ihren (Maven-basierten) 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>
Bitte lesen Sie diese Installationsanleitung, wenn Sie weitere Informationen benötigen.
Nachdem Sie nun die richtige API-Version eingerichtet haben, sehen wir uns einige der weit verbreiteten Fallbeispiele für die Bearbeitung Ihrer Multiformat-Dokumente an.
Das PDF-Format ist ein beliebter Dateityp, der für Dokumente, Berichte und andere digitale Inhalte verwendet wird. Es steht für Portable Document Format und wird aufgrund seiner Fähigkeit, qualitativ hochwertige Dokumente zu erstellen, die leicht zu teilen sind, weit verbreitet. Es unterscheidet sich von den anderen gängigen Datendateiformaten, da es ein festes Layout bietet und unabhängig vom Gerät und Betriebssystem, auf dem Sie es lesen oder anzeigen, die gleiche Formatierung und das gleiche Layout beibehält.
Aber was ist, wenn Sie Änderungen an einem PDF-Dokument vornehmen müssen? Das Bearbeiten von PDF-Dateien kann ein kniffliger Prozess sein, muss es aber nicht sein, wenn Sie GroupDocs.Editor für die .NET-API verwenden. Mit dieser API können Sie PDF-Dateien wie jedes andere Dokument mit einem WYSIWYG-Editor bearbeiten. Derzeit wird die PDF-Bearbeitung nur in der .NET-Version der GroupDocs.Editor-API und nicht in der Java-Version unterstützt.
Bitte verwenden Sie den folgenden Code zum Laden, Bearbeiten und anschließenden Speichern einer PDF-Datei 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(); Microsoft Word, Excel und PowerPoint sind weit verbreitete Formate zum Erstellen von Dokumenten, Tabellenkalkulationen bzw. Präsentationen. Sie werden in den meisten Unternehmen und Organisationen als Standardformate verwendet und sind unverzichtbare Werkzeuge für alle, die Daten effizient organisieren, analysieren und präsentieren möchten.
Möchten Sie eines dieser Dokumentformate programmgesteuert in .NET oder Java bearbeiten? Wenn ja, können Sie GroupDocs.Editor-APIs verwenden und Microsoft Word-, Excel- und PowerPoint-Dokumente bearbeiten, und dazu müsste nicht einmal Microsoft Office auf Ihrem System installiert sein.
Um Word-Dokumente (DOCX) in .NET zu bearbeiten, verwenden Sie bitte diesen 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);
}
}
}
}
} Verwenden Sie zum Bearbeiten von Word-Dokumenten in Java bitte den folgenden 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); Sie können Excel-Dokumente bearbeiten in .NET mit dem folgenden 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);
} Um Excel-Tabellenkalkulationen in Java zu bearbeiten, können Sie dieses Code-Snippet verwenden:
// 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()
In ähnlicher Weise können Sie auch PowerPoint-Präsentationen mit der GroupDocs.Editor-API bearbeiten. Bitte prüfen Sie .NET und Java-Bearbeitung-Leitfäden für weitere Hilfe.
Textdateien (mit TXT bezeichnet) sind eines der am häufigsten verwendeten Dateiformate, da sie leicht, einfach und einfach zu erstellen und zu teilen sind. Sie werden auf vielfältige Weise verwendet, vom Schreiben von Code bis zum Erstellen von reinen Textdokumenten. Textdokumente enthalten keine Textformatierungen, Bilder, Formulare, Tabellen oder andere Rich-Text-Elemente.
GroupDocs.Editor-APIs unterstützen die Bearbeitung von Textdateien in .NET- und Java-Plattformen. Sie können Bearbeitungsfunktionen für Textdokumente in Ihre vorhandene Anwendung integrieren und ihre Funktionen erweitern oder zu diesem Zweck Ihre eigene Texteditor-App erstellen.
Der unten angegebene Beispielcode kann zum Bearbeiten von Textdateien in .NET verwendet werden. Die bearbeitete Datei kann in den Formaten TXT und Textverarbeitung (DOCM) gespeichert werden:
//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); Um Textdateien in Java zu bearbeiten, können Sie den unten gezeigten Code verwenden. Anschließend können Sie das geänderte Dokument in den Dateiformaten TXT oder Word (DOCM) speichern:
// 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); E-Mail-Dokumente sind Dateien, die den Inhalt einer E-Mail-Nachricht enthalten, einschließlich des Nachrichtentexts und aller Anhänge. Diese Dateien werden normalerweise zum Übertragen von E-Mail-Nachrichten zwischen verschiedenen E-Mail-Clients oder zum Speichern in einem Standardformat verwendet. Sie werden von verschiedenen E-Mail-Clients wie Microsoft Outlook, Apple Mail und Mozilla Thunderbird verwendet. Diese Dokumente sind fester Bestandteil unserer Kommunikation im digitalen Zeitalter.
Mit der zunehmenden Verwendung dieser Dateitypen wird auch deren Bearbeitung üblich. Die Automatisierung des Bearbeitungsprozesses kann von unschätzbarem Wert sein, unabhängig davon, ob Sie den Prozess in ein anderes System integrieren oder benutzerdefinierte Logik integrieren möchten. GroupDocs.Editor-APIs (für .NET und Java) ermöglichen Ihnen genau das. Mit diesen APIs können Sie E-Mail-Dokumente gängiger Formate bearbeiten.
Wenn Sie eine E-Mail-Nachricht (MSG) laden, bearbeiten und speichern möchten, verwenden Sie dies bitte 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();
Zum Laden, Bearbeiten und Speichern einer E-Mail-Nachrichtendatei (MSG) können Sie den folgenden Code verwenden :
//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();
Sie können mit unserer auch PDF-, DOCX-, XLSX-, PPTX-, ODT-, ODS-, RTF-, TXT-, CSV-, XML-, EPUB- und viele andere Dokumente im Handumdrehen bearbeiten Kostenlose Apps zum Bearbeiten von Dokumenten von einem Gerät Ihrer Wahl, probieren Sie sie also gerne aus.
Sie können Daten aus verschiedenen verfügbaren Quellen wie JSON und CSV ganz einfach nach Microsoft Excel exportieren.
WeiterlesenSie haben mehrere Excel-Arbeitsmappen und möchten diese in einer Datei zusammenführen, um Berichte zu erstellen oder Daten an einem Ort zu speichern
WeiterlesenDas Konvertieren von Word-Dokumenten einschließlich DOC oder DOCX in .NET ist eine sehr häufige Anforderung
Weiterlesen