本文整理汇总了Java中org.docx4j.openpackaging.exceptions.InvalidFormatException类的典型用法代码示例。如果您正苦于以下问题:Java InvalidFormatException类的具体用法?Java InvalidFormatException怎么用?Java InvalidFormatException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InvalidFormatException类属于org.docx4j.openpackaging.exceptions包,在下文中一共展示了InvalidFormatException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createHeaderReference
import org.docx4j.openpackaging.exceptions.InvalidFormatException; //导入依赖的package包/类
public void createHeaderReference(
WordprocessingMLPackage wordprocessingMLPackage,
MainDocumentPart t, ObjectFactory factory, Relationship relationship)
throws InvalidFormatException {
List<SectionWrapper> sections = wordprocessingMLPackage
.getDocumentModel().getSections();
SectPr sectPr = sections.get(sections.size() - 1).getSectPr();
// There is always a section wrapper, but it might not contain a sectPr
if (sectPr == null) {
sectPr = factory.createSectPr();
t.addObject(sectPr);
sections.get(sections.size() - 1).setSectPr(sectPr);
}
HeaderReference headerReference = factory.createHeaderReference();
headerReference.setId(relationship.getId());
headerReference.setType(HdrFtrRef.DEFAULT);
sectPr.getEGHdrFtrReferences().add(headerReference);
}
示例2: createFooterReference
import org.docx4j.openpackaging.exceptions.InvalidFormatException; //导入依赖的package包/类
public void createFooterReference(
WordprocessingMLPackage wordprocessingMLPackage,
MainDocumentPart t, ObjectFactory factory, Relationship relationship)
throws InvalidFormatException {
List<SectionWrapper> sections = wordprocessingMLPackage
.getDocumentModel().getSections();
SectPr sectPr = sections.get(sections.size() - 1).getSectPr();
// There is always a section wrapper, but it might not contain a sectPr
if (sectPr == null) {
sectPr = factory.createSectPr();
t.addObject(sectPr);
sections.get(sections.size() - 1).setSectPr(sectPr);
}
FooterReference footerReference = factory.createFooterReference();
footerReference.setId(relationship.getId());
footerReference.setType(HdrFtrRef.DEFAULT);
sectPr.getEGHdrFtrReferences().add(footerReference);
}
示例3: createHeaderReference
import org.docx4j.openpackaging.exceptions.InvalidFormatException; //导入依赖的package包/类
/**
* 创建页眉引用关系
*
* @param word
* @param relationship
* @throws InvalidFormatException
*/
public static void createHeaderReference(
WordprocessingMLPackage word,
Relationship relationship )
throws InvalidFormatException {
List<SectionWrapper> sections = word.getDocumentModel().getSections();
SectPr sectPr = sections.get(sections.size() - 1).getSectPr();
// There is always a section wrapper, but it might not contain a sectPr
if (sectPr==null ) {
sectPr = factory.createSectPr();
word.getMainDocumentPart().addObject(sectPr);
sections.get(sections.size() - 1).setSectPr(sectPr);
}
HeaderReference headerReference = factory.createHeaderReference();
headerReference.setId(relationship.getId());
headerReference.setType(HdrFtrRef.DEFAULT);
sectPr.getEGHdrFtrReferences().add(headerReference);
}
示例4: createFooterReference
import org.docx4j.openpackaging.exceptions.InvalidFormatException; //导入依赖的package包/类
/**
* 创建页脚引用关系
*
* @param word
* @param relationship
* @throws InvalidFormatException
*/
public static void createFooterReference(
WordprocessingMLPackage word,
Relationship relationship )
throws InvalidFormatException {
List<SectionWrapper> sections = word.getDocumentModel().getSections();
SectPr sectPr = sections.get(sections.size() - 1).getSectPr();
// There is always a section wrapper, but it might not contain a sectPr
if (sectPr==null ) {
sectPr = factory.createSectPr();
word.getMainDocumentPart().addObject(sectPr);
sections.get(sections.size() - 1).setSectPr(sectPr);
}
FooterReference footerReference = factory.createFooterReference();
footerReference.setId(relationship.getId());
footerReference.setType(HdrFtrRef.DEFAULT);
sectPr.getEGHdrFtrReferences().add(footerReference);
}
示例5: createHeaderReference
import org.docx4j.openpackaging.exceptions.InvalidFormatException; //导入依赖的package包/类
public void createHeaderReference(
WordprocessingMLPackage wordprocessingMLPackage,
MainDocumentPart t, ObjectFactory factory, Relationship relationship)
throws InvalidFormatException {
List<SectionWrapper> sections = wordprocessingMLPackage
.getDocumentModel().getSections();
SectPr sectPr = sections.get(sections.size() - 1).getSectPr();
// There is always a section wrapper, but it might not contain a sectPr
if (sectPr == null) {
sectPr = factory.createSectPr();
t.addObject(sectPr);
sections.get(sections.size() - 1).setSectPr(sectPr);
}
HeaderReference headerReference = factory.createHeaderReference();
headerReference.setId(relationship.getId());
headerReference.setType(HdrFtrRef.DEFAULT);
sectPr.getEGHdrFtrReferences().add(headerReference);
}
示例6: createFooterReference
import org.docx4j.openpackaging.exceptions.InvalidFormatException; //导入依赖的package包/类
public void createFooterReference(
WordprocessingMLPackage wordprocessingMLPackage,
MainDocumentPart t, ObjectFactory factory, Relationship relationship)
throws InvalidFormatException {
List<SectionWrapper> sections = wordprocessingMLPackage
.getDocumentModel().getSections();
SectPr sectPr = sections.get(sections.size() - 1).getSectPr();
// There is always a section wrapper, but it might not contain a sectPr
if (sectPr == null) {
sectPr = factory.createSectPr();
t.addObject(sectPr);
sections.get(sections.size() - 1).setSectPr(sectPr);
}
FooterReference footerReference = factory.createFooterReference();
footerReference.setId(relationship.getId());
footerReference.setType(HdrFtrRef.DEFAULT);
sectPr.getEGHdrFtrReferences().add(footerReference);
}
示例7: createFooterReference
import org.docx4j.openpackaging.exceptions.InvalidFormatException; //导入依赖的package包/类
public static void createFooterReference(
WordprocessingMLPackage wordprocessingMLPackage,
Relationship relationship )
throws InvalidFormatException {
List<SectionWrapper> sections = wordprocessingMLPackage.getDocumentModel().getSections();
SectPr sectPr = sections.get(sections.size() - 1).getSectPr();
// There is always a section wrapper, but it might not contain a sectPr
if (sectPr==null ) {
sectPr = objectFactory.createSectPr();
wordprocessingMLPackage.getMainDocumentPart().addObject(sectPr);
sections.get(sections.size() - 1).setSectPr(sectPr);
}
FooterReference footerReference = objectFactory.createFooterReference();
footerReference.setId(relationship.getId());
footerReference.setType(HdrFtrRef.DEFAULT);
sectPr.getEGHdrFtrReferences().add(footerReference);// add header or
// footer references
}
示例8: createHeaderReference
import org.docx4j.openpackaging.exceptions.InvalidFormatException; //导入依赖的package包/类
public static void createHeaderReference(
WordprocessingMLPackage wordprocessingMLPackage,
Relationship relationship )
throws InvalidFormatException {
List<SectionWrapper> sections = wordprocessingMLPackage.getDocumentModel().getSections();
SectPr sectPr = sections.get(sections.size() - 1).getSectPr();
// There is always a section wrapper, but it might not contain a sectPr
if (sectPr==null ) {
sectPr = objectFactory.createSectPr();
wordprocessingMLPackage.getMainDocumentPart().addObject(sectPr);
sections.get(sections.size() - 1).setSectPr(sectPr);
}
HeaderReference headerReference = objectFactory.createHeaderReference();
headerReference.setId(relationship.getId());
headerReference.setType(HdrFtrRef.DEFAULT);
sectPr.getEGHdrFtrReferences().add(headerReference);// add header or
// footer references
}
示例9: initExport
import org.docx4j.openpackaging.exceptions.InvalidFormatException; //导入依赖的package包/类
@Override
protected void initExport() throws QueryException {
try {
factory = Context.getWmlObjectFactory();
for (int i=0; i<bean.getReportLayout().getColumnCount(); i++) {
rowSpanForColumn.put(i, 1);
}
if (!bean.isSubreport()) {
boolean landscape = (bean.getReportLayout().getOrientation() == LANDSCAPE);
wordMLPackage = WordprocessingMLPackage.createPackage(PageSizePaper.A4, landscape);
setPageMargins();
addMetadata();
}
table = createTable(PRINT_DOCUMENT);
} catch (InvalidFormatException e) {
e.printStackTrace();
throw new QueryException(e);
}
}
示例10: createFooterPart
import org.docx4j.openpackaging.exceptions.InvalidFormatException; //导入依赖的package包/类
/**
* As in the previous example, this method creates a footer part and adds it to
* the main document and then returns the corresponding relationship.
*
* @return
* @throws InvalidFormatException
*/
private static Relationship createFooterPart() throws InvalidFormatException {
FooterPart footerPart = new FooterPart();
footerPart.setPackage(wordMLPackage);
footerPart.setJaxbElement(createFooterWithPageNr());
return wordMLPackage.getMainDocumentPart().addTargetPart(footerPart);
}
示例11: addCommentPart
import org.docx4j.openpackaging.exceptions.InvalidFormatException; //导入依赖的package包/类
/**
* Creates comment part to the docx if not exists or returns the existing
* one
*
* @return : the comment part of the docx file
* @throws InvalidFormatException
*/
private org.docx4j.wml.Comments addCommentPart() throws InvalidFormatException {
// Create and add a Comments Part
org.docx4j.openpackaging.parts.WordprocessingML.CommentsPart commentsPart = new org.docx4j.openpackaging.parts.WordprocessingML.CommentsPart();
this.mdp.addTargetPart(commentsPart);
// Part must have minimal contents
Comments comments = this.wmlObjectFactory.createComments();
commentsPart.setJaxbElement(comments);
return comments;
}
示例12: getNumberingPart
import org.docx4j.openpackaging.exceptions.InvalidFormatException; //导入依赖的package包/类
/**
* Extracts the numbering parts of the docx file
*
* @return
*/
private org.docx4j.openpackaging.parts.WordprocessingML.NumberingDefinitionsPart getNumberingPart() {
org.docx4j.openpackaging.parts.WordprocessingML.NumberingDefinitionsPart numbering = null;
try {
numbering = (org.docx4j.openpackaging.parts.WordprocessingML.NumberingDefinitionsPart) this.wordMLPackage
.getParts().get(new PartName("/word/numbering.xml"));
if (numbering == null) {
HashMap<org.docx4j.openpackaging.parts.PartName, org.docx4j.openpackaging.parts.Part> mp = this.wordMLPackage
.getParts().getParts();
Iterator<java.util.Map.Entry<org.docx4j.openpackaging.parts.PartName, org.docx4j.openpackaging.parts.Part>> it = mp
.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<org.docx4j.openpackaging.parts.PartName, org.docx4j.openpackaging.parts.Part> pair = (Map.Entry<org.docx4j.openpackaging.parts.PartName, org.docx4j.openpackaging.parts.Part>) it
.next();
if (pair.getValue() instanceof org.docx4j.openpackaging.parts.WordprocessingML.NumberingDefinitionsPart) {
numbering = (org.docx4j.openpackaging.parts.WordprocessingML.NumberingDefinitionsPart) pair
.getValue();
break;
}
it.remove();
}
}
} catch (InvalidFormatException e) {
System.err.println("Couldn't load numbering part.");
}
return numbering;
}
示例13: addFooterWithPageNo
import org.docx4j.openpackaging.exceptions.InvalidFormatException; //导入依赖的package包/类
/**
* First we create the package and the factory. Then we create the footer.
* Finally we add two pages with text to the document and save it.
*/
static void addFooterWithPageNo(WordprocessingMLPackage wordMLPackage) {
ObjectFactory factory = Context.getWmlObjectFactory();
Relationship relationship = null;
try {
relationship = createFooterPart(wordMLPackage, factory);
} catch (InvalidFormatException e) {
LOGGER.error("Creating the footer part failed with " + e.getMessage());
LOGGER.debug(ExceptionUtils.getStackTrace(e));
}
createFooterReference(wordMLPackage, relationship, factory);
}
示例14: createFooterPart
import org.docx4j.openpackaging.exceptions.InvalidFormatException; //导入依赖的package包/类
/**
* As in the previous example, this method creates a footer part and adds it
* to the main document and then returns the corresponding relationship.
*
* @return
* @throws InvalidFormatException
*/
private static Relationship createFooterPart(WordprocessingMLPackage wordMLPackage, ObjectFactory factory) throws InvalidFormatException {
FooterPart footerPart = new FooterPart();
footerPart.setPackage(wordMLPackage);
footerPart.setJaxbElement(createFooterWithPageNr(factory));
return wordMLPackage.getMainDocumentPart().addTargetPart(footerPart);
}
示例15: createSlidePart
import org.docx4j.openpackaging.exceptions.InvalidFormatException; //导入依赖的package包/类
/**
* Create a slide and add it to the package
*
* @param pp
* @param layoutPart
* @param i
* @return the slide
* @throws InvalidFormatException
* @throws JAXBException
*/
private static SlidePart createSlidePart(MainPresentationPart pp, SlideLayoutPart layoutPart, int i)
throws InvalidFormatException, JAXBException {
// Slide part
SlidePart slidePart = new SlidePart(new PartName("/ppt/slides/slide" + i +".xml") );
pp.addSlideIdListEntry(slidePart);
slidePart.setJaxbElement( SlidePart.createSld() );
// Slide layout part
slidePart.addTargetPart(layoutPart);
return slidePart;
}