public final class Editor extends Object implements IAuxDisposable
Main class, which encapsulates conversion methods. Editor class provides methods for loading, editing, and saving documents of all supportable formats. It is disposable, so use a 'using' directive or dispose its resources manually via 'Dispose()' method call. Document loading is performed through constructors. Document editing - through method 'Edit', and saving back to the resultant document after edit - through method 'Save'.
Editor class should be considered as an entry point and the root object of the GroupDocs.Editor. All operations are performed using this class. Typical usage of the Editor class for performing a full document editing pipeline is the next:Disposed| Constructor and Description |
|---|
Editor(com.groupdocs.editor.formats.abstraction.DocumentFormatBase format)
Initializes a new instance of the
Editor class and creates a new empty document based on the specified format. |
Editor(InputStream document)
Initializes new Editor instance with specified input document (as a stream)
|
Editor(InputStream document,
ILoadOptions loadOptions)
Initializes new Editor instance with specified input document (as a
stream) with its load options and Editor settings
|
Editor(String filePath)
Initializes new Editor instance with specified input document (as a full file path)
|
Editor(String filePath,
ILoadOptions loadOptions)
Initializes new Editor instance with specified input document (as a full file path) with its load options
|
| Modifier and Type | Method and Description |
|---|---|
void |
dispose()
Disposes this instance of Editor, so that it releases all internal
resources and becomes unavailable for further usage
|
EditableDocument |
edit()
Opens a previously loaded document for editing using default options by
generating and returning an instance of 'EditableDocument' class, that,
in turn, contains methods for producing HTML markup and associated
resources.
|
EditableDocument |
edit(IEditOptions editOptions)
Opens a previously loaded document for editing using specified format-specific options by generating and returning an instance of '
|
IDocumentInfo |
getDocumentInfo(String password)
Returns metadata about the document, that was loaded to this 'Editor' instance
|
com.groupdocs.editor.FormFieldManager |
getFormFieldManager()
Provides access to functionality for managing form fields within the document.
|
boolean |
isDisposed()
Indicates whether this Editor instance was already disposed and cannot be
used anymore (true) or not and is active (false)
|
void |
save(EditableDocument inputDocument,
OutputStream outputDocument,
ISaveOptions saveOptions)
Converts specified edited document, represented as instance of
'EditableDocument', to the resultant document of specified format and
saves its content to specified stream
|
void |
save(EditableDocument inputDocument,
String filePath,
ISaveOptions saveOptions)
Converts specified edited document, represented as instance of '
|
OutputStream |
save(OutputStream outputDocument)
Save the current document content to the specified output stream.
|
OutputStream |
save(OutputStream outputDocument,
WordProcessingSaveOptions saveOptions)
Converts the original document after modification (for example,
FormFieldManager(getFormFieldManager())),
to the resultant document of the specified format and saves its content to the provided stream. |
public Editor(com.groupdocs.editor.formats.abstraction.DocumentFormatBase format)
throws Exception
Initializes a new instance of the Editor class and creates a new empty document based on the specified format.
IDocumentFormat format = WordProcessingFormats.Docx; Editor editor = new Editor(format); { // Use the editor instance to edit and save documents }
format - represents the file format of the document that will be created.
Learn more
Exceptionpublic Editor(InputStream document)
Initializes new Editor instance with specified input document (as a stream)
document - Delegate, that should return a stream with document content. Should not be NULL.
Learn more
public Editor(InputStream document, ILoadOptions loadOptions)
Initializes new Editor instance with specified input document (as a stream) with its load options and Editor settings
document - Delegate, that should return a stream with document
content. Should not be NULL.loadOptions - Delegate, that should return a document load options.
May be NULL and may return null - in that case document type will be
detected automatically and default load options for that type will be
applied.public Editor(String filePath)
Initializes new Editor instance with specified input document (as a full file path)
filePath - Full path to the file. Should not be NULL. Should be
valid, and file should exist.
Learn more
public Editor(String filePath, ILoadOptions loadOptions)
Initializes new Editor instance with specified input document (as a full file path) with its load options
filePath - Full path to the file. Should not be NULL. Should be valid, and file should exist.loadOptions - Delegate, that should return a document load options. May be NULL and may return null -
in that case document type will be detected automatically and default load options for that type will be applied.
Learn more
public final void dispose()
Disposes this instance of Editor, so that it releases all internal resources and becomes unavailable for further usage
dispose in interface IDisposablepublic final EditableDocument edit()
Opens a previously loaded document for editing using default options by generating and returning an instance of 'EditableDocument' class, that, in turn, contains methods for producing HTML markup and associated resources.
public final EditableDocument edit(IEditOptions editOptions)
Opens a previously loaded document for editing using specified format-specific options by generating and returning an instance of '
editOptions - Format-specific document options, which allows to
tune-up conversion process. Should not be NULL. Should not conflict with
previously applied load options.
Learn more
public final IDocumentInfo getDocumentInfo(String password)
Returns metadata about the document, that was loaded to this 'Editor' instance
password - User can specify a password for a document, if this document is encrypted with the password.
May be NULL or empty string, that is equivalent to the absent password. For those document formats, which do not have a password protection feature, this argument will be ignored. If the document is encrypted, and password in not specified in this parameter, but it was specified before in the load options while creating this public com.groupdocs.editor.FormFieldManager getFormFieldManager()
Provides access to functionality for managing form fields within the document.
FormFieldManager(getFormFieldManager()) instance for managing form fields within the document.
FormFieldManager(getFormFieldManager()) property creates a new instance of the FormFieldManager(getFormFieldManager()) class,
which allows access to methods and properties for managing form fields within the document.
Form fields are interactive elements within the document that can capture user input or trigger actions.
The FormFieldManager(getFormFieldManager()) instance provides methods for various form field operations,
including checking for invalid form fields, updating form field data, and fixing naming issues.
It also facilitates the retrieval of form field names and their associated data.
This property is useful for interacting with and manipulating form fields programmatically,
enabling tasks such as form field validation, synchronization, and customization.
public final boolean isDisposed()
Indicates whether this Editor instance was already disposed and cannot be used anymore (true) or not and is active (false)
isDisposed in interface IAuxDisposablepublic final void save(EditableDocument inputDocument, OutputStream outputDocument, ISaveOptions saveOptions)
Converts specified edited document, represented as instance of 'EditableDocument', to the resultant document of specified format and saves its content to specified stream
inputDocument - Version of the input document, that was edited in
WYSIWYG HTML-editor and is stored as instance of 'EditableDocument'
class, which should be converted to output document of some specific
formatoutputDocument - Output stream, in which the content of the
resultant document will be recorded. Should not be NULL, disposed, should
support writing.saveOptions - Document saving options, which define the format of
the resultant document, and also general and format-specific saving
options.
Learn more
public final void save(EditableDocument inputDocument, String filePath, ISaveOptions saveOptions)
Converts specified edited document, represented as instance of '
inputDocument - Version of the input document, that was edited in WYSIWYG HTML-editor and is stored as instance of 'filePath - Path to the file, in which the output document will be saved. It file with the same name exists, it will be completely rewritten. String with path must not be null, empty or contain only whitespaces.saveOptions - Document saving options, which define the format of the resultant document, and also general and format-specific saving options. Must not be null.
Learn more
public final OutputStream save(OutputStream outputDocument) throws Exception
Save the current document content to the specified output stream.
outputDocument - The stream to which the document content will be saved. This cannot be null.
NullPointerException - Thrown when outputDocument is null or if the document content is missing.Exceptionpublic final OutputStream save(OutputStream outputDocument, WordProcessingSaveOptions saveOptions) throws Exception
Converts the original document after modification (for example, FormFieldManager(getFormFieldManager())),
to the resultant document of the specified format and saves its content to the provided stream.
outputDocument - The stream to which the output document will be saved.
This stream should be writable and positioned at the start of the document content. Must not be null.saveOptions - Document saving options that define the format of the resultant document,
as well as general and format-specific saving options. Must not be null.
outputDocument or saveOptions is null, an NullPointerException will be thrown.
If the document to save is missing, an NullPointerException will be thrown.
<b>Learn more:</b>
NullPointerException - Thrown when outputDocument or saveOptions is null,
or when the document to save is missing.ExceptionWordProcessingSaveOptionsCopyright © 2024. All rights reserved.