Package org.docx4j.openpackaging.contenttype

Examples of org.docx4j.openpackaging.contenttype.ContentTypeManager


    // 2. Create a new Package
    //    Eventually, you'll also be able to create an Excel package etc
    //    but only the WordML package exists at present
   
    ContentTypeManager ctm = new ContentTypeManager();

    try {
      InputStream is = getInputStreamFromZippedPart( partByteArrays,  "[Content_Types].xml");   
      ctm.parseContentTypesFile(is);
    } catch (IOException e) {
      throw new Docx4JException("Couldn't get [Content_Types].xml from ZipFile", e);
    } catch (NullPointerException e) {
      throw new Docx4JException("Couldn't get [Content_Types].xml from ZipFile", e);
    }
   
    // .. now find the name of the main part
    RelationshipsPart rp = RelationshipsPart.createPackageRels();
    populatePackageRels(partByteArrays, rp);
   
    String mainPartName = PackageRelsUtil.getNameOfMainPart(rp);
    String pkgContentType = ctm.getContentType(new PartName("/" + mainPartName));

    // 2. Create a new Package; this'll return the appropriate subclass
    OpcPackage p = ctm.createPackage(pkgContentType);
    log.info("Instantiated package of type " + p.getClass().getName() );

    p.setRelationships(rp);
    rp.setSourceP(p); //
   
View Full Code Here

TOP

Related Classes of org.docx4j.openpackaging.contenttype.ContentTypeManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.