يشير تحرير المستند في سياق تعديل ملفاتك الرقمية إلى عملية تغيير النص أو الصور أو العناصر الأخرى داخل المستند. يمكن استخدام التحرير الرقمي لملفات البيانات لتحسين دقة المحتوى ووضوحه ، وإضافة تصحيحات إلى المحتوى الموجود ، وتسهيل قراءة المستند ، وغير ذلك الكثير. مع الاستخدام المتزايد باستمرار لأنواع مختلفة من المستندات الرقمية ، أصبحت الحاجة إلى تحريرها إلكترونيًا أكثر أهمية.
أصبحت القدرة على تحرير المستندات الرقمية إلكترونيًا مهارة أساسية لأي شخص يعمل مع المستندات. يمكن أن تكون معرفة كيفية تحرير ملفات PDF و Microsoft Office وملفات البيانات الأخرى بسرعة ودقة بمثابة توفير كبير للوقت. لهذا الغرض ، يمكنك استخدام GroupDocs.Editor APIs التي تدعم تحرير مجموعة من تنسيقات ملفات البيانات الشائعة مثل PDF و Word و Excel و PowerPoint و OpenDocument و RTF و Text و HTML والكتب الإلكترونية وغيرها الكثير عبر منصات .NET و Java .
لبدء تحرير مستنداتك في .NET أو Java ، ستحتاج أولاً إلى تثبيت الإصدار المطلوب من GroupDocs.Editor. يرجى الرجوع إلى الإرشادات المشتركة في الأقسام التالية لإعداد GroupDocs.Editor لـ .NET أو Java بشكل صحيح.
لا تتردد في تنزيل ملفات DLL أو مثبت MSI من قسم التنزيلات ، أو استخدم NuGet لتثبيت واجهة برمجة التطبيقات. يمكنك أيضًا استخدام وحدة تحكم مدير الحزم:
لمزيد من المساعدة بشأن التثبيت ، لا تتردد في مراجعة هذا الدليل .
بالنسبة لإصدار Java ، يمكنك إما تنزيل ملف JAR من قسم التنزيلات أو إضافة التكوينات التالية للمستودع و التبعية في تطبيقات Java (المستندة إلى Maven):
<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>
الرجاء مراجعة دليل التثبيت هذا إذا كنت بحاجة إلى مزيد من المعلومات.
الآن بعد أن انتهيت من إعداد إصدار API الصحيح ، دعنا نتحقق من بعض سيناريوهات الحالة المستخدمة على نطاق واسع لتحرير مستنداتك متعددة التنسيقات.
تنسيق PDF هو نوع ملف شائع يستخدم للمستندات والتقارير والمحتويات الرقمية الأخرى. إنه يرمز إلى تنسيق المستندات المحمولة ويستخدم على نطاق واسع نظرًا لقدرته على إنتاج مستندات عالية الجودة يسهل مشاركتها. وهو يختلف عن تنسيقات ملفات البيانات الشائعة الأخرى لأنه يوفر تخطيطًا ثابتًا ويحافظ على نفس التنسيق والتخطيط بغض النظر عن الجهاز ونظام التشغيل الذي تقرأه أو تشاهده عليه.
ولكن ماذا لو احتجت إلى إجراء تغييرات على مستند PDF؟ يمكن أن تكون عملية تحرير ملفات PDF صعبة ، ولكن لا يجب أن تكون كذلك إذا كنت تستخدم GroupDocs.Editor لـ .NET API. تمكنك واجهة برمجة التطبيقات هذه من تحرير ملفات PDF باستخدام محرر WYSIWYG مثل أي مستند آخر. حاليًا ، يتم دعم تحرير PDF فقط في إصدار .NET من GroupDocs.Editor API وليس في إصدار Java.
الرجاء استخدام الشفرة التالية من أجل تحميل وتحرير ثم حفظ ملف PDF في .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 و PowerPoint على نطاق واسع لإنشاء المستندات وجداول البيانات والعروض التقديمية على التوالي. يتم استخدامها باعتبارها التنسيقات القياسية في معظم الشركات والمؤسسات وهي أدوات أساسية لأي شخص يتطلع إلى تنظيم البيانات وتحليلها وتقديمها بطريقة فعالة.
هل تتطلع إلى تحرير أي من تنسيقات المستندات هذه برمجيًا في .NET أو Java؟ إذا كانت الإجابة بنعم ، يمكنك استخدام GroupDocs.Editor APIs وتعديل مستندات Microsoft Word و Excel و PowerPoint ولن تحتاج حتى إلى تثبيت Microsoft Office على نظامك للقيام بذلك.
لتحرير مستندات Word (DOCX) في .NET ، يرجى استخدام هذا الرمز :
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);
}
}
}
}
} لتحرير مستندات Word بجافا ، الرجاء استخدام الكود التالي :
// 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); يمكنك تحرير مستندات Excel في .NET باستخدام رمز C # التالي:
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);
} لتعديل Excel جداول البيانات في Java ، يمكنك استخدام مقتطف الشفرة هذا:
// 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()
وبالمثل ، يمكنك تحرير عروض PowerPoint التقديمية أيضًا باستخدام GroupDocs.Editor API. يرجى مراجعة .NET و تحرير جافا لمزيد من المساعدة.
تعد الملفات النصية (المشار إليها بواسطة TXT) واحدة من أكثر تنسيقات الملفات شيوعًا ، حيث إنها خفيفة الوزن وبسيطة وسهلة الإنشاء والمشاركة. يتم استخدامها بعدة طرق ، من كتابة التعليمات البرمجية إلى إنشاء مستندات نصية بسيطة فقط. لا تحتوي المستندات النصية على أي تنسيق نصي أو صور أو نماذج أو جداول أو أي عناصر نص منسق أخرى.
تدعم واجهات برمجة التطبيقات GroupDocs.Editor تحرير الملفات النصية في الأنظمة الأساسية .NET و Java. يمكنك دمج ميزات تحرير المستندات النصية في تطبيقك الحالي وتعزيز قدراته أو إنشاء تطبيق محرر نصوص خاص بك لهذا الغرض.
يمكن استخدام نموذج التعليمات البرمجية الموضح أدناه لتحرير الملفات النصية في .NET. يمكن حفظ الملف المحرر بتنسيق TXT وتنسيقات معالجة الكلمات (DOCM):
//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); لتحرير الملفات النصية في جافا ، يمكنك استخدام الشفرة الموضحة أدناه. يمكنك بعد ذلك حفظ المستند المعدل بتنسيق ملف TXT أو Word (DOCM):
// 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); مستندات البريد الإلكتروني هي ملفات تحتوي على محتوى رسالة بريد إلكتروني ، بما في ذلك نص الرسالة وأي مرفقات. تُستخدم هذه الملفات عادةً لنقل رسائل البريد الإلكتروني بين عملاء بريد إلكتروني مختلفين أو لتخزينها بتنسيق قياسي. يتم استخدامها من قبل العديد من عملاء البريد الإلكتروني مثل Microsoft Outlook و Apple Mail و Mozilla Thunderbird. تشكل هذه المستندات جزءًا لا يتجزأ من كيفية تواصلنا مع بعضنا البعض في العصر الرقمي.
مع زيادة استخدام أنواع الملفات هذه ، أصبح تحريرها شائعًا أيضًا. يمكن أن تكون أتمتة عملية التحرير لا تقدر بثمن سواء كنت ترغب في دمج العملية مع نظام آخر ، أو دمج منطق مخصص. تمكنك واجهات برمجة تطبيقات GroupDocs.Editor (لـ .NET و Java) من القيام بذلك. يمكنك تحرير مستندات البريد الإلكتروني ذات التنسيقات الشائعة باستخدام واجهات برمجة التطبيقات هذه.
إذا كنت تبحث عن تحميل وتحرير وحفظ رسالة بريد إلكتروني (MSG) ، فالرجاء استخدام هذا كود C #:
//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();
تحميل وتحرير وحفظ ملف رسالة بريد إلكتروني (MSG) ، يمكنك استخدام الكود التالي :
//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();
يمكنك أيضًا تحرير ملفات PDF و DOCX و XLSX و PPTX و ODT و ODS و RTF و TXT و CSV و XML و EPUB والعديد من المستندات الأخرى أثناء التنقل باستخدام تطبيقات تحرير المستندات المجانية من جهاز من اختيارك ، لذا لا تتردد في التحقق منها.
يمكنك بسهولة تصدير البيانات إلى Microsoft Excel من مختلف المصادر المتاحة مثل JSON و CSV.
أكمل القراءةلديك العديد من مصنفات Excel ، وتريد دمجها معًا في ملف واحد لإعداد التقارير أو للاحتفاظ بالبيانات في مكان واحد
أكمل القراءةيعد تحويل مستندات Word بما في ذلك DOC أو DOCX في .NET مطلبًا شائعًا جدًا
أكمل القراءة