public PropertyResolver getPropertyResolver() { if (propertyResolver==null) { try { propertyResolver = new PropertyResolver( (WordprocessingMLPackage)this.pack); } catch (Docx4JException e) { e.printStackTrace(); } } return propertyResolver; }
protected File setupRootFolder(BinaryPart binaryPart) throws Docx4JException { File folder = new File(imageDirPath); if ((folder.exists()) && (!folder.isDirectory())) { throw new Docx4JException("Invalid imageDirPath '" + imageDirPath + ", it isn't a directory"); } if (!folder.exists()) { if (!folder.mkdirs()) { throw new Docx4JException("Invalid imageDirPath '" + imageDirPath + ", could not create the directory"); } } return folder; }
/** * Get the live contents of this part. * (getContents() is preferred, this is the older/less friendly method name) * @return */ public E getJaxbElement() { try { return getContents(); } catch (Docx4JException e) { log.error(e.getMessage(), e); return null; } }
e.printStackTrace(); } catch (UnsupportedEncodingException e) { throw new Docx4JException("Couldn't find xpath with id: " + xpathId); if (cxp ==null) throw new Docx4JException("Couldn't find cxp with id: " + xpath.getDataBinding().getStoreItemID()); log.error(e.getMessage(), e);
/** * @param imageHandler * @param picture * @param relationship * @param part * @return uri for the image we've saved, or null */ protected String handlePart(ConversionImageHandler imageHandler, AbstractWordXmlPicture picture, Relationship relationship, BinaryPart binaryPart) { String uri = null; try { uri = imageHandler.handleImage(picture, relationship, binaryPart); } catch (Docx4JException de) { if (relationship != null) { log.error("Exception handling image id: " + relationship.getId() + ", target '" + relationship.getTarget() + "': " + de.toString(), de); } else { log.error("Exception handling image: " + de.toString(), de); } } return uri; }
private static Exporter<FOSettings> FOExporterVisitorGetInstance() throws Docx4JException { // Use reflection to return FOExporterVisitor.getInstance(); // so docx4j can be built without docx4j-export-FO try { Class<?> clazz = Class.forName("org.docx4j.convert.out.fo.FOExporterVisitor"); Method method = clazz.getMethod("getInstance", null); return (Exporter<FOSettings>)method.invoke(null, null); } catch (Exception e) { throw new Docx4JException("org.docx4j.convert.out.fo.FOExporterVisitor not found; if you want it, add docx4j-export-FO to your path. Doing so will disable Plutext's PDF Converter." + "/n" + e.getMessage(), e); } }
/** @since 2.7.2 */ @Override public OpcPackage clone() { OpcPackage result = null; // Zip it up ByteArrayOutputStream baos = new ByteArrayOutputStream(); SaveToZipFile saver = new SaveToZipFile(this); try { saver.save(baos); result = load(new ByteArrayInputStream(baos.toByteArray())); } catch (Docx4JException e) { // TODO Auto-generated catch block e.printStackTrace(); } return result; }
private List<Node> xpathGetNodes( Map<String, CustomXmlPart> customXmlDataStorageParts, String storeItemId, String xpath, String prefixMappings) { CustomXmlPart part = customXmlDataStorageParts .get(storeItemId.toLowerCase()); if (part == null) { log.error("Couldn't locate part by storeItemId " + storeItemId); return null; } try { return part.xpathGetNodes(xpath, prefixMappings); } catch (Docx4JException e) { log.error(e.getMessage(), e); return null; } }
private static Exporter<FOSettings> FOExporterXsltGetInstance() throws Docx4JException { // Use reflection to return FOExporterXslt.getInstance(); // so docx4j can be built without docx4j-export-FO try { Class<?> clazz = Class.forName("org.docx4j.convert.out.fo.FOExporterXslt"); Method method = clazz.getMethod("getInstance", null); return (Exporter<FOSettings>)method.invoke(null, null); } catch (Exception e) { throw new Docx4JException("org.docx4j.convert.out.fo.FOExporterXslt not found; if you want it, add docx4j-export-FO to your path. " + "/n" + e.getMessage(), e); } }
e.printStackTrace(); continue;
/** * Generate HTML for the entire MainDocumentPart. * @return */ public org.w3c.dom.Document export() { ByteArrayOutputStream outStream = new ByteArrayOutputStream(DEFAULT_OUTPUT_SIZE); Document ret = null; try { Docx4J.toHTML(htmlSettings, outStream, Docx4J.FLAG_EXPORT_PREFER_NONXSL); ret = XmlUtils.getNewDocumentBuilder().parse(new ByteArrayInputStream(outStream.toByteArray())); } catch (Docx4JException e) { log.error("Exception exporting document: " + e.getMessage(), e); } catch (SAXException e) { log.error("Exception parsing document: " + e.getMessage(), e); } catch (IOException e) { log.error("Exception parsing document: " + e.getMessage(), e); } return ret; }
private Object convertObject(Object id, Class c) throws Docx4JException { if (c.isAssignableFrom(id.getClass())) { return id; } if (c==BigInteger.class) { if (id instanceof Long) { return BigInteger.valueOf( (Long)id); } } throw new Docx4JException("TODO: Convert " + id.getClass().getName() + " to "+ c.getName() ); }
public static WordprocessingMLPackage getDefaultTemplate(InputStream inputStream) { try { final WordprocessingMLPackage mlPackage = WordprocessingMLPackage.load(inputStream); return mlPackage; } catch (Docx4JException e) { e.printStackTrace(); } return null; }
private void ensureContent() throws Pptx4jException { try { if (this.getContents()==null ) { throw new Pptx4jException("MainPresentationPart has no content"); } } catch (Docx4JException e) { throw new Pptx4jException(e.getMessage(), e); } }
/** * get the SignatureHelper object, so you can sign the package using custom settings. * * @param certificateIS * @param password * @return * @throws Docx4JException */ public Object getSignatureHelper() throws Docx4JException { try { Class<?> signingClass = Class.forName("com.plutext.dsig.SignatureHelper"); Constructor<?> ctor = signingClass.getConstructor(OpcPackage.class); return ctor.newInstance(this.pkg); } catch (Exception e) { log.warn("Docx4j Enterprise jar v3.3 or greater not found. Required for Digital Signatures."); throw new Docx4JException("missing Enterprise version required for Digital Signature functionality"); } }
public PropertyResolver getResolver() { if (myResolver == null) { try { myResolver = new PropertyResolver(myPackage); } catch (Docx4JException e) { e.printStackTrace(); } } return myResolver; }
log.error(e.getMessage(), e); throw new InputIntegrityException(e.getMessage());
public void finishSave() throws Docx4JException { try { // Complete the ZIP file // Don't forget to do this or everything will appear // to work, but when you open the zip file you'll get an error // "End-of-central-directory signature not found." zos.close(); } catch (Exception e ) { throw new Docx4JException("Failed to put binary part", e); } }
@Override public Part getContainerPart() { try { return myDocx.getFootnotesPart(); } catch (Docx4JException e) { e.printStackTrace(); return myDocx.getDocxDocument(); } }
private void ensureSldIdLst() throws Pptx4jException { try { if (this.getContents().getSldIdLst()==null) { throw new Pptx4jException("SldIdLst missing from MainPresentationPart"); } } catch (Docx4JException e) { throw new Pptx4jException(e.getMessage(), e); } }