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
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classWordprocessingMLPackage.FilterSettings -
Field Summary
Fields Modifier and Type Field Description protected GlossaryDocumentPartglossaryDocprotected static org.slf4j.Loggerlogprotected MainDocumentPartmainDocFields inherited from class org.docx4j.openpackaging.packages.OpcPackage
contentTypeManager, customXmlDataStorageParts, docPropsCorePart, docPropsCustomPart, docPropsExtendedPart, externalResources, handled, parts -
Constructor Summary
Constructors Constructor Description WordprocessingMLPackage()Constructor.WordprocessingMLPackage(ContentTypeManager contentTypeManager)Constructor. -
Method Summary
Modifier and Type Method Description voidattachTemplate(java.lang.String templatePath)Attach a template to this document.static WordprocessingMLPackagecreatePackage()Creates a WordprocessingMLPackage, using default page size and orientation.static WordprocessingMLPackagecreatePackage(PageSizePaper sz, boolean landscape)Creates a WordprocessingMLPackage, containing a MainDocumentPart (with content), Styles part, DocPropsCorePart part, and DocPropsExtendedPart.voidfilter(WordprocessingMLPackage.FilterSettings filterSettings)Deprecated.protected voidfinalize()DocumentModelgetDocumentModel()MappergetFontMapper()HeaderFooterPolicygetHeaderFooterPolicy()Deprecated.MainDocumentPartgetMainDocumentPart()ProtectDocumentgetProtectionSettings()static WordprocessingMLPackageload(java.io.File docxFile)Convenience method to create a WordprocessingMLPackage from an existing File (.docx zip or .xml Flat OPC).static WordprocessingMLPackageload(java.io.InputStream is)Convenience method to create a WordprocessingMLPackage from an existing stream(.docx zip or .xml Flat OPC).voidreset()Reinit fields so this pkg object can be re-used.voidsetFontMapper(Mapper fm)voidsetFontMapper(Mapper fm, boolean populate)booleansetPartShortcut(Part part, java.lang.String relationshipType)Tell the source Part about this target Part, so the source can use this part via a convenience method.voidtransform(javax.xml.transform.Templates xslt, java.util.Map<java.lang.String,java.lang.Object> transformParameters)Use an XSLT to alter the contents of this package.Methods inherited from class org.docx4j.openpackaging.packages.OpcPackage
addDocPropsCorePart, addDocPropsCustomPart, addDocPropsExtendedPart, clone, cloneAs, getContentTypeManager, getCustomXmlDataStorageParts, getDocPropsCorePart, getDocPropsCustomPart, getDocPropsExtendedPart, getExternalResources, getPackage, getParts, getSourcePartStore, getTargetPartStore, getTitle, isNew, load, load, load, load, load, load, load, load, load, load, name, save, save, save, save, save, save, setContentTypeManager, setName, setNew, setSourcePartStore, setTargetPartStore, setTitleMethods inherited from class org.docx4j.openpackaging.Base
addTargetPart, addTargetPart, addTargetPart, addTargetPart, getContentType, getPartName, getRelationshipsPart, getRelationshipsPart, getUserData, setContentType, setPartName, setRelationships, setUserData
-
Field Details
-
log
protected static org.slf4j.Logger log -
mainDoc
-
glossaryDoc
-
-
Constructor Details
-
WordprocessingMLPackage
public WordprocessingMLPackage()Constructor. Also creates a new content type manager -
WordprocessingMLPackage
Constructor.- Parameters:
contentTypeManager- The content type manager to use
-
-
Method Details
-
getProtectionSettings
-
getDocumentModel
-
getHeaderFooterPolicy
Deprecated. -
load
Convenience method to create a WordprocessingMLPackage from an existing File (.docx zip or .xml Flat OPC).- Parameters:
docxFile- The docx file- Throws:
Docx4JException
-
load
Convenience method to create a WordprocessingMLPackage from an existing stream(.docx zip or .xml Flat OPC).- Parameters:
docxFile- The docx file- Throws:
Docx4JException
-
setPartShortcut
Description copied from class:BaseTell the source Part about this target Part, so the source can use this part via a convenience method.- Overrides:
setPartShortcutin classOpcPackage- Returns:
- true if the source Part does use the target Part in a convenience method.
-
getMainDocumentPart
-
transform
public void transform(javax.xml.transform.Templates xslt, java.util.Map<java.lang.String,java.lang.Object> transformParameters) throws java.lang.ExceptionUse 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:
java.lang.Exception
-
filter
@Deprecated public void filter(WordprocessingMLPackage.FilterSettings filterSettings) throws java.lang.ExceptionDeprecated.- Throws:
java.lang.Exception
-
setFontMapper
- Throws:
java.lang.Exception
-
setFontMapper
- Parameters:
fm-populate-- Throws:
java.lang.Exception- Since:
- 3.0.1
-
getFontMapper
-
createPackage
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 InvalidFormatExceptionCreates 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(java.lang.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 java.lang.Throwable- Overrides:
finalizein classjava.lang.Object- Throws:
java.lang.Throwable
-
reset
public void reset()Reinit fields so this pkg object can be re-used.- Overrides:
resetin classOpcPackage- Since:
- 3.3.7
-