@Deprecated public abstract class Document extends DocumentPart implements com.aspose.ms.System.IDisposable, Closeable
Represents a document where a watermark can be placed.
This example demonstrates how to load and save a document of any supported format.
// Load a document from a file. Document document = Document.load("D:\\input.pdf"); // Use methods of Document class to add or remove watermarks. // Save changes. document.save("D:\\output.pdf"); document.close();
Modifier and Type | Method and Description |
---|---|
void |
close()
Deprecated.
|
void |
dispose()
Deprecated.
Disposes the current instance.
|
protected void |
dispose(boolean disposing)
Deprecated.
Disposes the current instance.
|
static SearchableObjects |
getDefaultSearchableObjects()
Deprecated.
Gets the document objects that are to be included in a watermark search by default.
|
static DocumentInfo |
getInfo(InputStream stream)
Deprecated.
Gets the information about the format of a document stored in the stream.
|
static DocumentInfo |
getInfo(String filePath)
Deprecated.
Gets the information about the format of a document stored in the file.
|
SearchableObjects |
getSearchableObjects()
Deprecated.
Gets the document objects that are to be included in a watermark search.
|
static <TDocument extends Document> |
load(Class<TDocument> documentType,
InputStream stream)
Deprecated.
Loads a new document from the specified stream.
|
static <TDocument extends Document> |
load(Class<TDocument> documentType,
InputStream stream,
LoadOptions loadOptions)
Deprecated.
Loads a new document from the specified stream.
|
static <TDocument extends Document> |
load(Class<TDocument> documentType,
String filePath)
Deprecated.
Loads a new document from the specified file.
|
static <TDocument extends Document> |
load(Class<TDocument> documentType,
String filePath,
LoadOptions loadOptions)
Deprecated.
Loads a new document from the specified file.
|
static Document |
load(InputStream stream)
Deprecated.
Loads a new document from the specified stream.
|
static Document |
load(InputStream stream,
LoadOptions loadOptions)
Deprecated.
Loads a new document from the specified stream.
|
static Document |
load(String filePath)
Deprecated.
Loads a new document from the specified file.
|
static Document |
load(String filePath,
LoadOptions loadOptions)
Deprecated.
Loads a new document from the specified file.
|
void |
save(OutputStream stream)
Deprecated.
Saves the document to the specified stream.
|
void |
save(String filePath)
Deprecated.
Saves the document to the specified file location.
|
static void |
setDefaultSearchableObjects(SearchableObjects value)
Deprecated.
Sets the document objects that are to be included in a watermark search by default.
|
void |
setSearchableObjects(SearchableObjects value)
Deprecated.
Sets the document objects that are to be included in a watermark search.
|
addWatermark, findImages, findImages, findWatermarks, findWatermarks
public static SearchableObjects getDefaultSearchableObjects()
Gets the document objects that are to be included in a watermark search by default.
This setting should be configured before document instance creation. It has no effect on already existing instances.
To configure searchable objects for a particular document instance, use SearchableObjects
property.
This example demonstrates how to remove hyperlinks with a particular url from a document of any supported format.
String inputFolder = "D:\\docs\\input\\"; String outputFolder = "D:\\docs\\output\\"; // Specify that only hyperlinks should be searched for. SearchableObjects searchableObjects = new SearchableObjects(); searchableObjects.setWordsSearchableObjects(WordsSearchableObjects.Hyperlinks); searchableObjects.setCellsSearchableObjects(CellsSearchableObjects.Hyperlinks); searchableObjects.setDiagramSearchableObjects(DiagramSearchableObjects.Hyperlinks); searchableObjects.setPdfSearchableObjects(PdfSearchableObjects.Hyperlinks); searchableObjects.setSlidesSearchableObjects(SlidesSearchableObjects.Hyperlinks); Document.setDefaultSearchableObjects(searchableObjects); File[] files = new File(inputFolder).listFiles(); for (File file : files) { if (file.isFile()) { Document doc = Document.load(file.getAbsolutePath()); // Specify the url to be searched for. TextSearchCriteria criteria = new TextSearchCriteria("someurl.com", false); PossibleWatermarkCollection watermarks = doc.findWatermarks(criteria); // Remove all found hyperlinks. watermarks.clear(); // Save changes. doc.save(outputFolder + file.getName()); doc.close(); } }
public static void setDefaultSearchableObjects(SearchableObjects value)
Sets the document objects that are to be included in a watermark search by default.
This setting should be configured before document instance creation. It has no effect on already existing instances.
To configure searchable objects for a particular document instance, use SearchableObjects
property.
value
- The document objects that are to be included in a watermark search by default.
This example demonstrates how to remove hyperlinks with a particular url from a document of any supported format.
String inputFolder = "D:\\docs\\input\\"; String outputFolder = "D:\\docs\\output\\"; // Specify that only hyperlinks should be searched for. SearchableObjects searchableObjects = new SearchableObjects(); searchableObjects.setWordsSearchableObjects(WordsSearchableObjects.Hyperlinks); searchableObjects.setCellsSearchableObjects(CellsSearchableObjects.Hyperlinks); searchableObjects.setDiagramSearchableObjects(DiagramSearchableObjects.Hyperlinks); searchableObjects.setPdfSearchableObjects(PdfSearchableObjects.Hyperlinks); searchableObjects.setSlidesSearchableObjects(SlidesSearchableObjects.Hyperlinks); Document.setDefaultSearchableObjects(searchableObjects); File[] files = new File(inputFolder).listFiles(); for (File file : files) { if (file.isFile()) { Document doc = Document.load(file.getAbsolutePath()); // Specify the url to be searched for. TextSearchCriteria criteria = new TextSearchCriteria("someurl.com", false); PossibleWatermarkCollection watermarks = doc.findWatermarks(criteria); // Remove all found hyperlinks. watermarks.clear(); // Save changes. doc.save(outputFolder + file.getName()); doc.close(); } }
public final SearchableObjects getSearchableObjects()
Gets the document objects that are to be included in a watermark search.
Note, this property also specifies document objects which are used in image search.
For more information see DocumentPart.FindWatermarks()
, DocumentPart.FindWatermarks(SearchCriteria)
,
DocumentPart.FindImages()
and DocumentPart.FindImages(ImageSearchCriteria)
methods.
This example demonstrates how to remove all XObjects and Artifacts from a pdf document.
Document doc = Document.load("D:\\input.pdf"); Specify that only XObjects and Artifacts should be searched for. doc.getSearchableObjects().setPdfSearchableObjects(PdfSearchableObjects.XObjects | PdfSearchableObjects.Artifacts); PossibleWatermarkCollection watermarks = doc.findWatermarks(); // Remove all found hyperlinks. watermarks.clear(); // Save changes. doc.save("D:\\output.pdf"); doc.close();
public final void setSearchableObjects(SearchableObjects value)
Sets the document objects that are to be included in a watermark search.
Note, this property also specifies document objects which are used in image search.
For more information see DocumentPart.FindWatermarks()
, DocumentPart.FindWatermarks(SearchCriteria)
,
DocumentPart.FindImages()
and DocumentPart.FindImages(ImageSearchCriteria)
methods.
value
- The document objects that are to be included in a watermark search.
This example demonstrates how to remove all XObjects and Artifacts from a pdf document.
Document doc = Document.load("D:\\input.pdf"); Specify that only XObjects and Artifacts should be searched for. doc.getSearchableObjects().setPdfSearchableObjects(PdfSearchableObjects.XObjects | PdfSearchableObjects.Artifacts); PossibleWatermarkCollection watermarks = doc.findWatermarks(); // Remove all found hyperlinks. watermarks.clear(); // Save changes. doc.save("D:\\output.pdf"); doc.close();
public static Document load(String filePath)
Loads a new document from the specified file.
filePath
- The file path to load document from.Document
class.UnsupportedFileTypeException
- Supplied document type is not supported.public static Document load(String filePath, LoadOptions loadOptions)
Loads a new document from the specified file.
filePath
- The file path to load document from.loadOptions
- Additional options to use when loading a document.Document
class.UnsupportedFileTypeException
- Supplied document type is not supported.public static Document load(InputStream stream)
Loads a new document from the specified stream.
stream
- The stream to load document from.Document
class.UnsupportedFileTypeException
- Supplied document type is not supported.public static Document load(InputStream stream, LoadOptions loadOptions)
Loads a new document from the specified stream.
stream
- The stream to load document from.loadOptions
- Additional options to use when loading a document.Document
class.UnsupportedFileTypeException
- Supplied document type is not supported.public static DocumentInfo getInfo(InputStream stream)
Gets the information about the format of a document stored in the stream.
stream
- The stream containing a document.
This example demonstrates how to get information about a document of any supported type.
InputStream stream = new FileInputStream("D:\\test.ppt"); DocumentInfo docInfo = Document.getInfo(stream); System.out.println(docInfo.getFileFormat()); System.out.println(docInfo.isEncrypted()); stream.close();
DocumentInfo
instance that contains detected information.public static DocumentInfo getInfo(String filePath)
Gets the information about the format of a document stored in the file.
filePath
- The file path.
This example demonstrates how to get information about a document of any supported type.
DocumentInfo docInfo = Document.getInfo("D:\\test.ppt"); System.out.println(docInfo.getFileFormat()); System.out.println(docInfo.isEncrypted());
DocumentInfo
instance that contains detected information.public static <TDocument extends Document> TDocument load(Class<TDocument> documentType, String filePath)
Loads a new document from the specified file.
filePath
- The file path to load document from.documentType
- Expected document type (according to specified file type).
TDocument
: Expected document type (according to specified file type).
TDocument
class.UnsupportedFileTypeException
- Supplied document type is not supported.public static <TDocument extends Document> TDocument load(Class<TDocument> documentType, String filePath, LoadOptions loadOptions)
Loads a new document from the specified file.
filePath
- The file path to load document from.loadOptions
- Additional options to use when loading a document.documentType
- Expected document type (according to specified file type).
TDocument
: Expected document type (according to specified file type).
TDocument
class.UnsupportedFileTypeException
- Supplied document type is not supported.public static <TDocument extends Document> TDocument load(Class<TDocument> documentType, InputStream stream)
Loads a new document from the specified stream.
stream
- The stream to load document from.documentType
- Expected document type (according to specified file type).
TDocument
: Expected document type (according to specified stream content).
TDocument
class.UnsupportedFileTypeException
- Supplied document type is not supported.public static <TDocument extends Document> TDocument load(Class<TDocument> documentType, InputStream stream, LoadOptions loadOptions)
Loads a new document from the specified stream.
stream
- The stream to load document from.loadOptions
- Additional options to use when loading a document.documentType
- Expected document type (according to specified file type).
TDocument
: Expected document type (according to specified stream content).
TDocument
class.UnsupportedFileTypeException
- Supplied document type is not supported.public final void save(String filePath)
Saves the document to the specified file location.
filePath
- The file path to save the document data to.public final void save(OutputStream stream)
Saves the document to the specified stream.
stream
- The stream to save the document data to.public final void dispose()
Disposes the current instance.
dispose
in interface com.aspose.ms.System.IDisposable
protected void dispose(boolean disposing)
Disposes the current instance.
disposing
- True to release both managed and unmanaged resources;
false to release only unmanaged resources.public final void close()
close
in interface Closeable
close
in interface AutoCloseable
Copyright © 2020. All rights reserved.