Package org.docx4j.openpackaging.exceptions

Examples of org.docx4j.openpackaging.exceptions.Docx4JException


                info = getImageInfo(new URL("file://" + imageFile.getAbsolutePath()));
       
        // Debug ...
        displayImageInfo(info);
      } else {
        throw new Docx4JException("Unsupported linked image type.");
      }
    } catch (Exception e) {
      throw new Docx4JException("Error checking image format", e);
    }
    return info;
  }
View Full Code Here


      try {

        docDefaults = (DocDefaults) XmlUtils
            .unmarshalString(docDefaultsString);
      } catch (JAXBException e) {
        throw new Docx4JException("Problem unmarshalling "
            + docDefaultsString, e);
      }
    }

    // Setup documentDefaultPPr
    PPr documentDefaultPPr;
    if (docDefaults.getPPrDefault() == null) {
      log.warn("No PPrDefault present");
      try {
        documentDefaultPPr = (PPr) XmlUtils
            .unmarshalString(pPrDefaultsString);
      } catch (JAXBException e) {
        throw new Docx4JException("Problem unmarshalling "
            + pPrDefaultsString, e);
      }

    } else {
      documentDefaultPPr = docDefaults.getPPrDefault().getPPr();
      if (documentDefaultPPr==null) {
        documentDefaultPPr = Context.getWmlObjectFactory().createPPr();
      }
    }
   
    // If the docDefaults have no setting for w:spacing
    // then add it:
    if (documentDefaultPPr.getSpacing()==null) {
      Spacing spacing = Context.getWmlObjectFactory().createPPrBaseSpacing();
      documentDefaultPPr.setSpacing(spacing);
      spacing.setBefore(BigInteger.ZERO);
      spacing.setAfter(BigInteger.ZERO);
      spacing.setLine(BigInteger.valueOf(240));
    }

    // Setup documentDefaultRPr
    RPr documentDefaultRPr;
    if (docDefaults.getRPrDefault() == null) {
      log.warn("No RPrDefault present");
      try {
        documentDefaultRPr = (RPr) XmlUtils
            .unmarshalString(rPrDefaultsString);
          // that includes font size 10
      } catch (JAXBException e) {
        throw new Docx4JException("Problem unmarshalling "
            + rPrDefaultsString, e);
      }
    } else {
      documentDefaultRPr = docDefaults.getRPrDefault().getRPr();
      if (documentDefaultRPr==null) {
View Full Code Here

    // In principle, that part should be identical in both
    // openDopePkg and instancePkg.
    // We'll get it from instancePkg
    XPathsPart xPathsPart = ((WordprocessingMLPackage)instancePkg).getMainDocumentPart().getXPathsPart();
    if ( xPathsPart==null) {
      throw new Docx4JException("OpenDoPE XPaths part missing");
    }
   
    for ( Object entry : instanceSdtPrFinder.boundSdtPotentialRepair ) {
     
      // If the SDT was made to contain a w:hyperlink, we had to remove:
View Full Code Here

      log.debug("image file name: " + filename);

      uri = storeImage(binaryPart, bytes, folder, filename);
    }
    catch (FileSystemException fse) {
      throw new Docx4JException(fse.toString(), fse);
    }
    catch (IOException ioe) {
      throw new Docx4JException(ioe.toString(), ioe);
    }
    return uri;
  }
View Full Code Here

    try {
      FileObject fo = VFS.getManager().resolveFile(filepath);
      thePackage = getPackageFromFileObject(fo);
    } catch (FileSystemException exc) {
      exc.printStackTrace();
      throw new Docx4JException("Couldn't get FileObject", exc);
    }
    return thePackage;
  }
View Full Code Here

        localCopy.close();
       
        thePackage = getPackageFromLocalFile(localCopy);
      } catch (FileSystemException exc) {
        exc.printStackTrace();
        throw new Docx4JException("Could not create a temporary local copy", exc);
      } finally {
        if (localCopy != null) {
          try {
            localCopy.delete();
          } catch (FileSystemException exc) {
View Full Code Here

  public OpcPackage getPackageFromLocalFile(LocalFile fo) throws Docx4JException {
    OpcPackage thePackage = null;
   
    String localPath = VFSUtils.getLocalFilePath(fo);
    if (localPath == null) {
      throw new Docx4JException("Couldn't get local path");
    }
   
    thePackage = _loadFromZipFile.get(new File(localPath));
    return thePackage;
  }
View Full Code Here

    try {
      writer = new OutputStreamWriter(outputStream, "UTF-8");
      writer.write(foDocument);
      writer.flush();
    } catch (Exception e) {
      throw new Docx4JException("Exception while storing fo document to OutputStream: " + e.getMessage(), e);
    }
  }
View Full Code Here

        localCopy = (LocalFile) VFS.getManager().resolveFile(tmpPath);
        localCopy.copyFrom(in, new FileTypeSelector(FileType.FILE));
        localCopy.close();
      } catch (FileSystemException exc) {
        exc.printStackTrace();
        throw new Docx4JException(
            "Could not create a temporary local copy", exc);
      } finally {
        if (localCopy != null) {
          try {
            localCopy.delete();
          } catch (FileSystemException exc) {
            exc.printStackTrace();
            log.warn("Couldn't delete temporary file " + tmpPath);
          }
        }
      }
    } else {
      localCopy = (LocalFile) in;
    }

    String localPath = VFSUtils.getLocalFilePath(in);
    if (localPath == null) {
      throw new Docx4JException("Couldn't get local path");
    }
   
    return Doc.convert(new FileInputStream(localPath));
  }
View Full Code Here

    try {
      FileObject fo = VFS.getManager().resolveFile(filepath);
      success = save(fo);
    } catch (FileSystemException exc) {
      exc.printStackTrace();
      throw new Docx4JException("Couldn't get FileObject", exc);
    }
   
    return success;
  }
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.