Class DocumentUtil
java.lang.Object
org.wickedsource.docxstamper.util.DocumentUtil
Utility class to retrieve elements from a document.
- Version:
- ${version}
- Author:
- Joseph Verron
-
Method Summary
Modifier and TypeMethodDescriptionallElements(org.docx4j.openpackaging.packages.WordprocessingMLPackage subDocument) Retrieve the last element from an object.static List<org.docx4j.wml.P> getParagraphsFromObject(Object parentObject) Retrieve all the paragraphs from a documentstatic List<org.docx4j.wml.Tc> getTableCellsFromObject(Object parentObject) Retrieve all the cells from an object.static List<org.docx4j.wml.Tbl> getTableFromObject(Object parentObject) Retrieve all the tables from an object.static List<org.docx4j.wml.Tr> getTableRowsFromObject(Object parentObject) Retrieve all the rows from an object.static ObjectlastElement(org.docx4j.openpackaging.packages.WordprocessingMLPackage subDocument) Retrieve the first element from an object.static <T> Stream<T> streamElements(Object object, Class<T> elementClass) Retrieve all the elements of a given class from an object.static Stream<org.docx4j.wml.P> streamParagraphs(org.docx4j.openpackaging.packages.WordprocessingMLPackage document) Retrieve all the runs from a document.static Map<org.docx4j.wml.R, org.docx4j.wml.R> walkObjectsAndImportImages(org.docx4j.openpackaging.packages.WordprocessingMLPackage source, org.docx4j.openpackaging.packages.WordprocessingMLPackage target) Recursively walk through source to find embedded images and import them in the target document.static Map<org.docx4j.wml.R, org.docx4j.wml.R> walkObjectsAndImportImages(org.docx4j.wml.ContentAccessor container, org.docx4j.openpackaging.packages.WordprocessingMLPackage source, org.docx4j.openpackaging.packages.WordprocessingMLPackage target) Recursively walk through source accessor to find embedded images and import the target document.
-
Method Details
-
getParagraphsFromObject
Retrieve all the paragraphs from a document- Parameters:
parentObject- the document to get the paragraphs from- Returns:
- a list of paragraphs
-
streamElements
Retrieve all the elements of a given class from an object.- Type Parameters:
T- the type of the elements to get- Parameters:
object- the object to get the elements fromelementClass- the class of the elements to get- Returns:
- a stream of the elements
-
getTableFromObject
Retrieve all the tables from an object.- Parameters:
parentObject- the object to get the tables from- Returns:
- a list of tables
-
getTableRowsFromObject
Retrieve all the rows from an object.- Parameters:
parentObject- the object to get the rows from- Returns:
- a list of rows
-
getTableCellsFromObject
Retrieve all the cells from an object.- Parameters:
parentObject- the object to get the cells from- Returns:
- a list of cells
-
lastElement
public static Object lastElement(org.docx4j.openpackaging.packages.WordprocessingMLPackage subDocument) Retrieve the first element from an object.- Parameters:
subDocument- the object to get the first element from- Returns:
- the first element
-
allElements
public static List<Object> allElements(org.docx4j.openpackaging.packages.WordprocessingMLPackage subDocument) Retrieve the last element from an object.- Parameters:
subDocument- the object to get the last element from- Returns:
- the last element
-
walkObjectsAndImportImages
public static Map<org.docx4j.wml.R,org.docx4j.wml.R> walkObjectsAndImportImages(org.docx4j.openpackaging.packages.WordprocessingMLPackage source, org.docx4j.openpackaging.packages.WordprocessingMLPackage target) Recursively walk through source to find embedded images and import them in the target document.- Parameters:
source- source document containing image files.target- target document to add image files to.- Returns:
- a
Mapobject
-
walkObjectsAndImportImages
public static Map<org.docx4j.wml.R,org.docx4j.wml.R> walkObjectsAndImportImages(org.docx4j.wml.ContentAccessor container, org.docx4j.openpackaging.packages.WordprocessingMLPackage source, org.docx4j.openpackaging.packages.WordprocessingMLPackage target) Recursively walk through source accessor to find embedded images and import the target document.- Parameters:
container- source container to walk.source- source document containing image files.target- target document to add image files to.- Returns:
- a
Mapobject
-
streamParagraphs
public static Stream<org.docx4j.wml.P> streamParagraphs(org.docx4j.openpackaging.packages.WordprocessingMLPackage document) Retrieve all the runs from a document.- Parameters:
document- the document to get the runs from- Returns:
- the runs
-