Package org.docx4j.openpackaging.exceptions

Examples of org.docx4j.openpackaging.exceptions.Docx4JException


    if (parts.get("/word/document.xml")!=null) {
      packageResult = new  WordprocessingMLPackage(ctm);
    } else if (parts.get("/ppt/presentation.xml")!=null) {
      packageResult = new  PresentationMLPackage(ctm);
    } else {
      throw new Docx4JException("Unrecognised package");
    }
    log.info("Creating " + packageResult.getClass().getName() );
   
    // 4. Start with _rels/.rels
View Full Code Here


      rp = p.getRelationshipsPart(true);
      populateRelationshipsPart(rp,  part.getXmlData().getAny());
                 
    } catch (Exception e) {
      e.printStackTrace();
      throw new Docx4JException("Error getting document from XmlPackage:" + partName, e);
     
    }
   
    return rp;
  }
View Full Code Here

          + " Source is " + rp.getSourceP().getPartName()
          + ", Target is " + r.getTarget() );
      try {       
        getPart(pkg, rp, r);
      } catch (Exception e) {
        throw new Docx4JException("Failed to add parts from relationships", e);
      }
    }
   
   
   
View Full Code Here

        ((BinaryPart)part).setBinaryData( pkgPart.getBinaryData() );
      }
    } catch (Exception ex) {
      // IOException, URISyntaxException
      ex.printStackTrace();
      throw new Docx4JException("Failed to getPart", ex);     
     
    }
    return part;
  }
View Full Code Here

  InputStream inStream = null;
    try {
      targetURI = new URI(absoluteTarget.replace('\\', '/'));
    }
    catch (URISyntaxException use) {
      throw new Docx4JException("Invalid absolute Target: '" + absoluteTarget + "'", use);
    }
    try {
      targetURL = targetURI.toURL();
    } catch (MalformedURLException mue) {
      throw new Docx4JException("Invalid absolute Target: '" + absoluteTarget + "'", mue);
    }
    try {
      inStream = targetURL.openStream();
      binaryPart = createBinaryPart(absoluteTarget, contentType);
      binaryPart.setBinaryData(inStream);
    } catch (IOException ioe) {
      throw new Docx4JException("Could not load external resource: '" + absoluteTarget + "'", ioe);
    }
    return binaryPart;
  }
View Full Code Here

 
       
      } catch (ClassNotFoundException e) {
      } catch (NoSuchMethodException e) {
      } catch (Exception e) {
        throw new Docx4JException("Problem processing w:altChunk", e);
     
    }
   
    // Either demonstrate reverter, or stripping of controls;
    // you can't do both. So comment out one or the other.
View Full Code Here

      if (rel.getType().equals(
          "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument") ) {
        return rel.getTarget();
      }
    }
    throw new Docx4JException("No relationship of type officeDocument");
  }
View Full Code Here

    FileOutputStream fos = null;
    try {
      fos = new FileOutputStream(docxFile);
      saver.save(fos);
    } catch (FileNotFoundException e) {
      throw new Docx4JException("Couldn't save " + docxFile.getPath(), e);
    } finally {
      IOUtils.closeQuietly(fos);
    }     
   
  }
View Full Code Here

      ByteArrayOutputStream baos2 = new ByteArrayOutputStream();
      try {
          marshal(baos);
      other.marshal(baos2);
    } catch (JAXBException e) {
      throw new Docx4JException("Error marshalling parts", e);
    }
     
      return java.util.Arrays.equals(baos.toByteArray(), baos2.toByteArray());

    }
View Full Code Here

   
    try {
      return OpcPackage.load(name, new FileInputStream(docxFile), password );
    } catch (final FileNotFoundException e) {
      OpcPackage.log.error(e.getMessage(), e);
      throw new Docx4JException("Couldn't load file from " + docxFile.getAbsolutePath(), e);
    }
  }
View Full Code Here

TOP

Related Classes of org.docx4j.openpackaging.exceptions.Docx4JException

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.