Class DocumentUtil


  • public class DocumentUtil
    extends Object
    • Method Detail

      • prepareDocumentForInsert

        public static List<Object> prepareDocumentForInsert​(org.docx4j.openpackaging.packages.WordprocessingMLPackage sourceDocument,
                                                            org.docx4j.openpackaging.packages.WordprocessingMLPackage targetDocument)
                                                     throws Exception
        Recursively walk through the content accessor to replace embedded images and import the matching files to the destination document before importing content.
        Parameters:
        sourceDocument - document to import.
        targetDocument - document to add the source document content to.
        Returns:
        the whole content of the source document with imported images replaced.
        Throws:
        Exception
      • walkObjectsAndImportImages

        public static List<Object> walkObjectsAndImportImages​(org.docx4j.wml.ContentAccessor sourceContainer,
                                                              org.docx4j.openpackaging.packages.WordprocessingMLPackage sourceDocument,
                                                              org.docx4j.openpackaging.packages.WordprocessingMLPackage destDocument)
                                                       throws Exception
        Recursively walk through the content accessor to replace embedded images and import the matching files to the destination document.
        Parameters:
        sourceContainer - source container to walk.
        sourceDocument - source document containing image files.
        destDocument - destination document to add image files to.
        Returns:
        the list of imported objects from the source container.
        Throws:
        Exception
      • extractElements

        public static <T> List<T> extractElements​(Object object,
                                                  Class<T> elementClass)
      • getImageRelationshipId

        public static String getImageRelationshipId​(org.docx4j.wml.Drawing drawing)
        Retrieve an embedded drawing relationship id.
        Parameters:
        drawing - the drawing to get the relationship id.
        Returns:
        the id of the graphic
      • getParagraphsFromObject

        public static List<org.docx4j.wml.P> getParagraphsFromObject​(Object parentObject)
      • getTableFromObject

        public static List<org.docx4j.wml.Tbl> getTableFromObject​(Object parentObject)
      • getTableRowsFromObject

        public static List<org.docx4j.wml.Tr> getTableRowsFromObject​(Object parentObject)
      • getTableCellsFromObject

        public static List<org.docx4j.wml.Tc> getTableCellsFromObject​(Object parentObject)