Tagraíonn eagarthóireacht doiciméad i gcomhthéacs do chomhaid dhigiteacha a mhodhnú don phróiseas a bhaineann le téacs, íomhánna nó gnéithe eile laistigh de dhoiciméad a athrú. D’fhéadfaí eagarthóireacht dhigiteach ar chomhaid sonraí a úsáid chun cruinneas agus soiléireacht an ábhair a fheabhsú, ceartúcháin a chur leis an ábhar atá ann cheana féin, an doiciméad a dhéanamh níos éasca le léamh, agus go leor eile. Agus méadú ag teacht ar úsáid na gcineálacha éagsúla doiciméad digiteacha de shíor, tá an gá atá le heagarthóireacht leictreonach a dhéanamh orthu ag éirí níos tábhachtaí.
Is scil riachtanach anois é an cumas doiciméid dhigiteacha a chur in eagar go leictreonach d’aon duine a oibríonn le doiciméid. Is mór an t-am é a bheith eolach ar conas PDF, Microsoft Office agus comhaid sonraí eile a chur in eagar go tapa agus go cruinn. Chun na críche sin, is féidir leat APIs GroupDocs.Editor a úsáid a thacaíonn le heagarthóireacht a dhéanamh ar raon formáidí comhaid sonraí a bhfuil tóir orthu mar PDF, Word, Excel, PowerPoint, OpenDocument, RTF, Téacs, HTML, ríomhleabhair, agus go leor eile ar fud ardáin .NET agus Java .
Chun tús a chur le do dhoiciméid a chur in eagar in .NET nó Java, beidh ort an leagan riachtanach de GroupDocs.Editor a shuiteáil ar dtús. Déan tagairt le do thoil do na treoracha atá roinnte sna hailt seo a leanas chun GroupDocs.Editor a shocrú i gceart do .NET nó Java.
Ná bíodh drogall ort na DLLanna nó an suiteálaí MSI a íoslódáil ón rannóg íoslódálacha, nó úsáid NuGet chun an API a shuiteáil. Is féidir leat an Consól Bainisteoir Pacáistí a úsáid freisin:
Le haghaidh tuilleadh cabhrach leis an tsuiteáil, bíodh leisce ort an treoir seo a sheiceáil.
Maidir leis an leagan Java, is féidir leat an comhad JAR a íoslódáil ón rannán íoslódálacha nó na cumraíochtaí seo a leanas a chur leis don stór agus spleáchas i do chuid aipeanna Java (bunaithe ar 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>
Déan athbhreithniú ar an treoir suiteála seo má tá tuilleadh eolais uait.
Anois agus an leagan ceart API déanta agat, déanaimis seiceáil ar chuid de na cásanna a úsáidtear go forleathan chun do dhoiciméid ilfhormáideacha a chur in eagar.
Is cineál comhaid coitianta é formáid PDF a úsáidtear le haghaidh doiciméid, tuarascálacha agus ábhar digiteach eile. Seasann sé do Formáid Doiciméad Iniompartha agus úsáidtear go forleathan é mar gheall ar a chumas doiciméid ardchaighdeáin a tháirgeadh atá éasca le roinnt. Tá sé difriúil ó na formáidí comhaid sonraí eile a bhfuil tóir orthu mar go dtugann sé leagan amach atá socraithe agus coinníonn sé an fhormáidiú agus an leagan amach céanna beag beann ar an bhfeiste agus ar an gcóras oibriúcháin a bhfuil tú ag léamh nó ag féachaint air.
Ach cad a tharlóidh má theastaíonn uait athruithe a dhéanamh ar dhoiciméad PDF? Is próiseas deacair é comhaid PDF a chur in eagar, ach ní gá go mbeadh sé amhlaidh má tá GroupDocs.Editor in úsáid agat le haghaidh .NET API. Cuireann an API seo ar do chumas comhaid PDF a chur in eagar ag baint úsáide as eagarthóir WYSIWYG cosúil le haon doiciméad eile. Faoi láthair, ní thacaítear le heagarthóireacht PDF ach sa leagan .NET de GroupDocs.Editor API agus ní sa leagan Java.
Bain úsáid as an gcód seo a leanas le do luchtú, eagarthóireacht, agus ansin comhad PDF a shábháil 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(); Is formáidí a úsáidtear go forleathan iad Microsoft Word, Excel, agus PowerPoint chun doiciméid, scarbhileoga agus cur i láthair a chruthú. Úsáidtear iad mar na formáidí caighdeánacha i bhformhór na ngnólachtaí agus na n-eagraíochtaí agus is uirlisí riachtanacha iad d’aon duine atá ag iarraidh sonraí a eagrú, a anailísiú agus a chur i láthair ar bhealach éifeachtach.
An bhfuil tú ag iarraidh aon cheann de na formáidí doiciméad seo a chur in eagar go cláir i .NET nó i Java? Má tá, is féidir leat GroupDocs.Editor APIs a úsáid agus doiciméid Microsoft Word, Excel, agus PowerPoint a chur in eagar agus ní fiú go mbeadh Microsoft Office suiteáilte ar do chóras chun é seo a dhéanamh.
Chun doiciméid Word (DOCX) a chur in eagar i .NET, úsáid an cód seo le do thoil:
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);
}
}
}
}
} Chun doiciméid Word a chur in eagar i Java, úsáid an cód seo a leanas:
// 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); Is féidir leat doiciméid Excel a chur in eagar in .NET leis an gcód C# seo a leanas:
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);
} Chun Excel scarbhileoga i Java a chur in eagar, is féidir leat an mhír chóid seo a úsáid:
// 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()
Mar an gcéanna, is féidir leat cuir i láthair PowerPoint a chur in eagar freisin ag baint úsáide as GroupDocs.Editor API. Seiceáil le do thoil an .NET agus Eagarthóireacht Java treoracha le haghaidh tuilleadh cabhrach.
Tá comhaid téacs (arna sonrú ag TXT) ar cheann de na formáidí comhaid is coitianta a úsáidtear, mar go bhfuil siad éadrom, simplí, agus éasca le cruthú agus le roinnt. Baintear úsáid astu ar bhealaí éagsúla, ó chód a scríobh go doiciméid shimplí téacs-amháin a chruthú. Níl aon fhormáidiú téacs, íomhánna, foirmeacha, táblaí, nó aon eilimintí téacs saibhir eile i ndoiciméid téacs.
Tacaíonn APIanna GroupDocs.Editor le comhaid téacs a chur in eagar in ardáin .NET agus Java. Is féidir leat gnéithe eagarthóireachta doiciméad téacs a chomhtháthú isteach i d'fheidhmchlár reatha agus a chumais a fheabhsú nó d'aip eagarthóirí téacs féin a thógáil chun na críche sin.
Is féidir an cód samplach thíos a úsáid chun comhaid téacs a chur in eagar in .NET. D’fhéadfaí an comhad a cuireadh in eagar a shábháil i bhformáidí TXT agus próiseála focal (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); Chun comhaid téacs a chur in eagar i Java, is féidir leat an cód a thaispeántar thíos a úsáid. Is féidir leat an doiciméad modhnaithe a shábháil ansin chuig formáidí comhaid TXT nó 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); Is comhaid iad doiciméid ríomhphoist ina bhfuil ábhar teachtaireacht ríomhphoist, lena n-áirítear corp na teachtaireachta agus aon cheangaltáin. Úsáidtear na comhaid seo de ghnáth chun teachtaireachtaí ríomhphoist a aistriú idir cliaint ríomhphoist éagsúla nó chun iad a stóráil i bhformáid chaighdeánach. Úsáideann cliaint ríomhphoist éagsúla iad, mar shampla Microsoft Outlook, Apple Mail, agus Mozilla Thunderbird. Is cuid lárnach iad na doiciméid seo den chaoi a ndéanaimid cumarsáid lena chéile san aois dhigiteach.
Leis an méadú ar úsáid na gcineálacha comhaid seo, tá eagarthóireacht orthu ag éirí coitianta freisin. Is féidir leis an bpróiseas eagarthóireachta uathoibriú a bheith fíor-luachmhar cibé acu is mian leat an próiseas a chomhtháthú le córas eile, nó loighic shaincheaptha a ionchorprú. Cuireann APInna GroupDocs.Editor (do .NET agus Java) ar do chumas é sin a dhéanamh. Is féidir leat doiciméid ríomhphoist de bhformáidí coitianta a chur in eagar ag baint úsáide as na APIanna seo.
Má tá tú ag iarraidh teachtaireacht ríomhphoist a luchtú, a chur in eagar agus a shábháil (MSG), úsáid é seo le do thoil Cód 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();
Chun comhad teachtaireachta ríomhphoist (MSG) a lódáil, a chur in eagar agus a shábháil, is féidir leat an cód seo a leanas a úsáid :
//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();
Is féidir leat PDF, DOCX, XLSX, PPTX, ODT, ODS, RTF, TXT, CSV, XML, EPUB, agus go leor doiciméad eile ar an eitilt a chur in eagar ag baint úsáide as ár Aipeanna um Eagarthóireacht Doiciméid In Aisce ó do rogha gléas mar sin bíodh leisce ort iad a sheiceáil amach.
Is féidir leat sonraí a onnmhairiú go héasca go Microsoft Excel ó fhoinsí éagsúla atá ar fáil ar nós JSON, agus CSV.
Leanúint ar aghaidh ag léamhTá roinnt leabhair oibre Excel agat, agus ba mhaith leat iad a chomhcheangal le chéile in aon chomhad amháin chun sonraí a thuairisciú nó chun sonraí a choinneáil in aon áit amháin
Leanúint ar aghaidh ag léamhIs riachtanas an-choitianta é doiciméid Word a thiontú lena n-áirítear DOC nó DOCX in .NET
Leanúint ar aghaidh ag léamh