Examples of Docx4JException


Examples of org.docx4j.openpackaging.exceptions.Docx4JException

    try {
      Transformer serializer = tfactory.newTransformer();
      serializer.setOutputProperty(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes");
      serializer.transform( new DOMSource( getFlatDomDocument( (WordprocessingMLPackage)packageIn)) , result );       
    } catch (Exception e) {
      throw new Docx4JException("Failed to create Flat OPC output", e);
    }
   
  }
View Full Code Here

Examples of org.docx4j.openpackaging.exceptions.Docx4JException

  WordprocessingMLPackage wmlPackage = null;
    try {
      wmlPackage = (WordprocessingMLPackage)conversionSettings.getWmlPackage();
    }
    catch (ClassCastException cce) {
      throw new Docx4JException("Invalid document package in the settings, it isn't a WordprocessingMLPackage");
    }
    if (wmlPackage == null) {
      throw new Docx4JException("Missing WordprocessingMLPackage in the conversion settings");
    }
    return Preprocess.process(wmlPackage, conversionSettings.getFeatures());
  }
View Full Code Here

Examples of org.docx4j.openpackaging.exceptions.Docx4JException

        index = ((java.util.List)p.getParent()).indexOf(p);
        P newP = FieldsPreprocessor.canonicalise(p, fieldRefs);
//        log.debug("NewP length: " + newP.getContent().size() );
        ((java.util.List)p.getParent()).set(index, newP);       
      } else {
        throw new Docx4JException ("Unexpected parent: " + p.getParent().getClass().getName() );
      }
    }
   
    // Populate
    for (FieldRef fr : fieldRefs) {
View Full Code Here

Examples of org.docx4j.openpackaging.exceptions.Docx4JException

            ((WordprocessingMLPackage)ret).setFontMapper(
                ((WordprocessingMLPackage)opcPackage).getFontMapper(), false); //don't repopulate, since we want to preserve existing mappings
          } catch (Exception e) {
            // shouldn't happen
            log.error(e.getMessage(),e);
            throw new Docx4JException("Error setting font mapper on copy", e);
          }
        }
       
      }
    }
View Full Code Here

Examples of org.docx4j.openpackaging.exceptions.Docx4JException

   
    OpcPackage ret = null;
    try {
      ret = opcPackage.getClass().newInstance();
    } catch (InstantiationException e) {
      throw new Docx4JException("InstantiationException duplicating package", e);
    } catch (IllegalAccessException e) {
      throw new Docx4JException("IllegalAccessException duplicating package", e);
    }
   
//    contentType
    ret.setContentType(new ContentType(opcPackage.getContentType()));
//    partName
View Full Code Here

Examples of org.docx4j.openpackaging.exceptions.Docx4JException

               
      org.docx4j.XmlUtils.transform(doc, xslt, null, result);
     
      part.setJaxbElement(result);
    } catch (Exception e) {
      throw new Docx4JException("Problems transforming fields", e);     
    }
       
  }
View Full Code Here

Examples of org.docx4j.openpackaging.exceptions.Docx4JException

  protected static Part copyPart(Part part, OpcPackage targetPackage, boolean deepCopy) throws Docx4JException {
  Part ret = null;
    try {
      ret = part.getClass().getConstructor(PartName.class).newInstance(part.getPartName());
    } catch (Exception e) {
      throw new Docx4JException("Error cloning part of class " + part.getClass().getName(), e);
    }
    ret.setRelationshipType(part.getRelationshipType());
    ret.setContentType(new ContentType(part.getContentType()));
    if (targetPackage != null) {
      ret.setPackage(targetPackage);
View Full Code Here

Examples of org.docx4j.openpackaging.exceptions.Docx4JException

//    } catch (Docx4JException e) {
//      log.error(e.getMessage(), e);
//      throw e;
    } catch (IllegalArgumentException e) {
      if (e.getMessage().contains("Only non-null Positions with an index can be checked")) {
        throw new Docx4JException("Exception exporting package; FOP https://issues.apache.org/bugzilla/show_bug.cgi?id=54094 .. try PP_APACHEFOP_DISABLE_PAGEBREAK_LIST_ITEM",e);       
      } else {
        throw new Docx4JException("Exception exporting package", e);
      }
    } catch (Exception e) {
      log.error("Exception exporting package", e);
      throw new Docx4JException("Exception exporting package", e);
    } finally {
      // Clean-up
      try {
        outputStream.close();
      } catch (IOException e) {
View Full Code Here

Examples of org.docx4j.openpackaging.exceptions.Docx4JException

  public void setDocument(InputStream is) throws Docx4JException {
    try {
            DocumentBuilder documentBuilder = XmlUtils.getNewDocumentBuilder()
            doc = documentBuilder.parse(is);
    } catch (Exception e) {
      throw new Docx4JException("Problems parsing InputStream for part " + this.getPartName().getName(), e);
    }
  } 
View Full Code Here

Examples of org.docx4j.openpackaging.exceptions.Docx4JException

      } else {
        log.debug(xpathString + " ---> '" + result + "'");
      }
      return result;
    } catch (Exception e) {
      throw new Docx4JException("Problems evaluating xpath '" + xpathString + "'", e);
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.