Skip to content

Commit 93831d7

Browse files
committed
EDITORJAVA-1058 - Updated GroupDocs.Editor for Java up to 24.4 version
1 parent ded49ce commit 93831d7

6 files changed

Lines changed: 153 additions & 27 deletions

File tree

Demos/Dropwizard/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
<dependency>
7777
<groupId>com.groupdocs</groupId>
7878
<artifactId>groupdocs-editor</artifactId>
79-
<version>23.2</version>
79+
<version>24.4</version>
8080
<type>jar</type>
8181
</dependency>
8282
<dependency>

Demos/Spring/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@
143143
<dependency>
144144
<groupId>com.groupdocs</groupId>
145145
<artifactId>groupdocs-editor</artifactId>
146-
<version>23.2</version>
146+
<version>24.4</version>
147147
<type>jar</type>
148148
</dependency>
149149

Examples/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<dependency>
1414
<groupId>com.groupdocs</groupId>
1515
<artifactId>groupdocs-editor</artifactId>
16-
<version>23.9</version>
16+
<version>24.4</version>
1717
</dependency>
1818
<dependency>
1919
<groupId>commons-io</groupId>

Examples/src/main/java/com/groupdocs/editor/examples/MainClass.java

Lines changed: 55 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22

33
import com.groupdocs.editor.examples.advancedusage.*;
44
import com.groupdocs.editor.examples.advancedusage.editabledocumentexamples.*;
5-
import com.groupdocs.editor.examples.basicusage.EditDocument;
6-
import com.groupdocs.editor.examples.basicusage.Introduction;
7-
import com.groupdocs.editor.examples.basicusage.LoadDocument;
8-
import com.groupdocs.editor.examples.basicusage.SaveDocument;
5+
import com.groupdocs.editor.examples.basicusage.*;
96
import com.groupdocs.editor.examples.quickstart.HelloWorld;
107
import com.groupdocs.editor.examples.quickstart.SetLicenseFromFile;
118
import com.groupdocs.editor.examples.quickstart.SetLicenseFromStream;
@@ -15,55 +12,90 @@ public class MainClass {
1512

1613
public static void main(String[] args) throws Throwable {
1714

18-
//QuickStart usage
19-
//HelloWorld.run();
15+
System.out.print("Using GroupDocs.Editor for Java version " + com.groupdocs.editor.Editor.class.getPackage().getSpecificationVersion() );
16+
System.out.print("Open Program.cs. \nIn main() method uncomment the example that you want to run.");
17+
System.out.print("Output folder is '"+Constants.OutputPath+"'" );
18+
System.out.print("=====================================================");
19+
//region Quick Start
20+
2021
SetLicenseFromFile.run();
22+
//QuickStart.SetLicenseFromStream.run();
23+
//QuickStart.SetMeteredLicense.run();
24+
//HelloWorld.run();
2125

22-
//SetLicenseFromStream.run();
23-
//SetMeteredLicense.run();
26+
//endregion
27+
28+
////// *** Documents Editor Examples (Un-Comment to run each example demo methods) ***
29+
30+
//region Here are basic examples
2431

25-
//Basic usage
26-
//EditDocument.run();
2732
//Introduction.run();
33+
2834
//LoadDocument.run();
35+
36+
//EditDocument.run();
37+
2938
//SaveDocument.run();
3039

31-
//Advanced usage
40+
//CreateDocument.run();
41+
42+
//endregion
43+
44+
//region Advanced usage
45+
3246
//WorkingWithWordProcessing.run();
47+
3348
//WorkingWithSpreadsheetPasswordProtected.run();
49+
3450
//WorkingWithSpreadsheetMultiTab.run();
51+
3552
//WorkingWithDsv.run();
36-
//WorkingWithEmail.run();
37-
//WorkingWithMarkdown.run();
38-
//EditingMarkdown.run();
39-
//MarkdownRoundtrip.run();
53+
4054
//WorkingWithPresentations.run();
41-
//WorkingWithPresentationPreview.run();
55+
4256
//WorkingWithPlainTextDocuments.run();
57+
4358
//WorkingWithXml.run();
44-
//WorkingWithXml.loadXml();
45-
//WorkingWithXml.editXmlShort();
46-
//WorkingWithXml.highlightOptionsDemo();
47-
//WorkingWithXml.formatOptionsDemo();
48-
//WorkingWithXml.complexEditDemo();
49-
//WorkingWithXml.getXmlMetainfo();
59+
5060
//ExtractingDocumentInfo.run();
61+
5162
//SavingEditedDocumentToAllFormats.run();
63+
5264
//WorkingWithFormats.run();
5365

54-
// Working with EditableDocument
66+
//endregion
67+
68+
//region Working with EditableDocument
69+
5570
//CreateEditableDocumentFromHtmlFile.run();
71+
5672
//CreateEditableDocumentFromInnerBody.run();
73+
5774
//GetHtmlContent.run();
75+
5876
//GetHtmlContentWithPrefix.run();
77+
5978
//GetHtmlBodyContent.run();
79+
6080
//GetHtmlBodyContentWithPrefix.run();
81+
6182
//GetAllEmbeddedHtmlContent.run();
83+
6284
//GetExternalCssContent.run();
85+
6386
//GetExternalCssContentWithPrefix.run();
87+
6488
//SaveHtmlToFolder.run();
89+
6590
//SaveHtmlResourcesToFolder.run();
91+
6692
//WorkingWithResources.run();
93+
6794
//EditableDocumentAdvancedUsage.run();
95+
96+
//endregion
97+
98+
System.out.print("\r\n\r\n__________________________\r\nAll done. Press any key to exit.");
99+
68100
}
69101
}

Examples/src/main/java/com/groupdocs/editor/examples/advancedusage/editabledocumentexamples/CreateEditableDocumentFromInnerBody.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public static void run() throws Exception {
3131
String pathToResourceFolder = Constants.SAMPLE_HTML_BODY_RESOURCES;
3232

3333
//4. Initialize EditableDocument
34-
EditableDocument inputDoc = EditableDocument.fromBodyMarkupAndResourceFolder(content, pathToResourceFolder);
34+
EditableDocument inputDoc = EditableDocument.fromMarkupAndResourceFolder(content, pathToResourceFolder);
3535

3636
//5. Check obtained document
3737
System.out.println("There should be 2 stylesheets, and actually is " + inputDoc.getCss().size());
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
package com.groupdocs.editor.examples.basicusage;
2+
3+
import com.groupdocs.editor.EditableDocument;
4+
import com.groupdocs.editor.Editor;
5+
import com.groupdocs.editor.formats.*;
6+
import com.groupdocs.editor.options.*;
7+
import java.io.ByteArrayOutputStream;
8+
import java.io.InputStream;
9+
10+
/*
11+
* This example demonstrates how to create new documents by format in GroupDocs.Editor and apply edit options.
12+
*/
13+
public class CreateDocument {
14+
public static void run() throws Exception
15+
{
16+
17+
// Create a new WordProcessing document and save it using a callback .
18+
Editor editorWord = new Editor(document -> saveNewDocument(document), WordProcessingFormats.Docx);
19+
{
20+
// Edit the WordProcessing document with default options.
21+
EditableDocument defaultWordProcessingDoc = editorWord.edit();
22+
23+
// Edit the WordProcessing document with specified options and some defined settings.
24+
WordProcessingEditOptions wordProcessingEditOptions = new WordProcessingEditOptions();
25+
wordProcessingEditOptions.setEnablePagination(false); // Disable pagination for the document.
26+
wordProcessingEditOptions.setEnableLanguageInformation(true); // Enable language information for the document.
27+
wordProcessingEditOptions.setFontExtraction(FontExtractionOptions.ExtractAllEmbedded); // Extract all embedded fonts.
28+
29+
EditableDocument editableWordProcessingDocument = editorWord.edit(wordProcessingEditOptions);
30+
}
31+
32+
// Create a new Spreadsheet document and save it via callback .
33+
Editor editorSpreadsheet = new Editor(document -> saveNewDocument(document), SpreadsheetFormats.Xlsx);
34+
{
35+
// Edit the Spreadsheet document with default options.
36+
EditableDocument defaultEditableSpreadsheetDocument = editorSpreadsheet.edit();
37+
38+
// Edit the Spreadsheet document with specified options and some defined settings.
39+
SpreadsheetEditOptions spreadsheetEditOptions = new SpreadsheetEditOptions();
40+
spreadsheetEditOptions.setWorksheetIndex(0);
41+
spreadsheetEditOptions.setExcludeHiddenWorksheets(true);
42+
43+
EditableDocument editableSpreadsheetDocument = editorSpreadsheet.edit(spreadsheetEditOptions);
44+
}
45+
46+
// Create a new Presentation document and save it via callback Action<Stream>.
47+
Editor editorPresentation = new Editor(document -> saveNewDocument(document), PresentationFormats.Pptx);
48+
{
49+
// Edit the Presentation document with default options.
50+
EditableDocument defaultEditablePresentationDocument = editorPresentation.edit();
51+
52+
// Edit the Presentation document with specified options and some defined settings.
53+
PresentationEditOptions presentationEditOptions = new PresentationEditOptions();
54+
presentationEditOptions.setShowHiddenSlides(false);
55+
presentationEditOptions.setSlideNumber(0);
56+
57+
EditableDocument editablePresentationDocument = editorPresentation.edit(presentationEditOptions);
58+
}
59+
60+
// Create a new Email document and save it via callback .
61+
Editor editorEmail = new Editor(document -> saveNewDocument(document), EmailFormats.Eml);
62+
{
63+
// Edit the Email document with default options.
64+
EditableDocument defaultEditableEmailDocument = editorEmail.edit();
65+
66+
// Edit the Email document with specified options and some defined settings.
67+
EmailEditOptions emailEditOptions = new EmailEditOptions();
68+
emailEditOptions.setMailMessageOutput(MailMessageOutput.All);
69+
70+
EditableDocument editableEmailDocument = editorEmail.edit(emailEditOptions);
71+
}
72+
// Display completion message
73+
System.out.println("CreateDocument routine has successfully finished");
74+
}
75+
76+
// Callback function to save the new document stream
77+
static void saveNewDocument(InputStream document)
78+
{
79+
try /*JAVA: was using*/
80+
{
81+
ByteArrayOutputStream out = new ByteArrayOutputStream();
82+
83+
byte[] buf = new byte[1024];
84+
int len;
85+
while ((len = document.read(buf)) > 0) {
86+
out.write(buf, 0, len);
87+
}
88+
document.close();
89+
out.close();
90+
} catch (Exception e){
91+
throw new RuntimeException(e.getMessage());
92+
}
93+
}
94+
}

0 commit comments

Comments
 (0)