Class WordprocessingMLPackage

java.lang.Object
org.docx4j.openpackaging.Base
org.docx4j.openpackaging.packages.OpcPackage
org.docx4j.openpackaging.packages.WordprocessingMLPackage
All Implemented Interfaces:
PackageIdentifier
Direct Known Subclasses:
WordprocessingMLTemplatePackage

public class WordprocessingMLPackage extends OpcPackage
Author:
jharrop
  • Field Details

  • Constructor Details

    • WordprocessingMLPackage

      public WordprocessingMLPackage()
      Constructor. Also creates a new content type manager
    • WordprocessingMLPackage

      public WordprocessingMLPackage(ContentTypeManager contentTypeManager)
      Constructor.
      Parameters:
      contentTypeManager - The content type manager to use
  • Method Details

    • getProtectionSettings

      public ProtectDocument getProtectionSettings()
    • getDocumentModel

      public DocumentModel getDocumentModel()
    • getHeaderFooterPolicy

      @Deprecated public HeaderFooterPolicy getHeaderFooterPolicy()
      Deprecated.
    • load

      public static WordprocessingMLPackage load(File docxFile) throws Docx4JException
      Convenience method to create a WordprocessingMLPackage from an existing File (.docx zip or .xml Flat OPC).
      Parameters:
      docxFile - The docx file
      Throws:
      Docx4JException
    • load

      public static WordprocessingMLPackage load(InputStream is) throws Docx4JException
      Convenience method to create a WordprocessingMLPackage from an existing stream(.docx zip or .xml Flat OPC).
      Parameters:
      docxFile - The docx file
      Throws:
      Docx4JException
    • setPartShortcut

      public boolean setPartShortcut(Part part, String relationshipType)
      Description copied from class: Base
      Tell the source Part about this target Part, so the source can use this part via a convenience method.
      Overrides:
      setPartShortcut in class OpcPackage
      Returns:
      true if the source Part does use the target Part in a convenience method.
    • getMainDocumentPart

      public MainDocumentPart getMainDocumentPart()
    • transform

      public void transform(Templates xslt, Map<String,Object> transformParameters) throws Exception
      Use an XSLT to alter the contents of this package. The output of the transformation must be valid pck:package/pck:part format, as emitted by Word 2007.
      Parameters:
      is -
      transformParameters -
      Throws:
      Exception
    • filter

      @Deprecated public void filter(WordprocessingMLPackage.FilterSettings filterSettings) throws Exception
      Deprecated.
      Throws:
      Exception
    • setFontMapper

      public void setFontMapper(Mapper fm) throws Exception
      Throws:
      Exception
    • setFontMapper

      public void setFontMapper(Mapper fm, boolean populate) throws Exception
      Parameters:
      fm -
      populate -
      Throws:
      Exception
      Since:
      3.0.1
    • getFontMapper

      public Mapper getFontMapper()
    • createPackage

      public static WordprocessingMLPackage createPackage() throws InvalidFormatException
      Creates a WordprocessingMLPackage, using default page size and orientation. From 2.7.1, these are read from docx4j.properties, or if not found, default to A4 portrait. The WordprocessingMLPackage contains a MainDocumentPart (with content), Styles part, DocPropsCorePart part, and DocPropsExtendedPart.
      Throws:
      InvalidFormatException
    • createPackage

      public static WordprocessingMLPackage createPackage(PageSizePaper sz, boolean landscape) throws InvalidFormatException
      Creates a WordprocessingMLPackage, containing a MainDocumentPart (with content), Styles part, DocPropsCorePart part, and DocPropsExtendedPart. The content contains sectPr specifying paper size and orientation.
      Parameters:
      sz -
      landscape -
      Returns:
      Throws:
      InvalidFormatException
    • attachTemplate

      public void attachTemplate(String templatePath)
      Attach a template to this document. This is just an easy way to access the same method in DocumentSettingsPart (which lives under the MainDocumentPart)
      Parameters:
      templatePath -
      Since:
      6.1.0
    • finalize

      protected void finalize() throws Throwable
      Overrides:
      finalize in class Object
      Throws:
      Throwable
    • reset

      public void reset()
      Reinit fields so this pkg object can be re-used.
      Overrides:
      reset in class OpcPackage
      Since:
      3.3.7