Package org.docx4j.openpackaging.packages

Examples of org.docx4j.openpackaging.packages.WordprocessingMLPackage$FilterSettings


   
    String inputfilepath = System.getProperty("user.dir")
      + "/sample-docs/word/2010/2010-mcAlternateContent.docx";       
   
   
    WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load(new java.io.File(inputfilepath));       

    // Since the JAXB binding stuff seems to remember
    // old artifacts, we'll first create a 'clean' object here
    // from something we've marshalled to. 
    org.w3c.dom.Document xmlNode = XmlUtils.marshaltoW3CDomDocument(
        wordMLPackage.getMainDocumentPart().getCommentsPart().getJaxbElement());       
    Binder<Node> binder = Context.jc.createBinder();
    Object jaxbElement =  (Comments) binder.unmarshal(xmlNode);
           
    List<Object> list = XmlUtils.getJAXBNodesViaXPath(binder, jaxbElement,
        "//w:pict/v:oval", false );   
View Full Code Here


   
    String inputfilepath = System.getProperty("user.dir")
      + "/sample-docs/word/2010/2010-mcAlternateContent-MDP.docx";       
   
   
    WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load(new java.io.File(inputfilepath));       

    // Since the JAXB binding stuff seems to remember
    // old artifacts, we'll first create a 'clean' object here
    // from something we've marshalled to. 
    org.w3c.dom.Document xmlNode = XmlUtils.marshaltoW3CDomDocument(
        wordMLPackage.getMainDocumentPart().getJaxbElement());       
    Binder<Node> binder = Context.jc.createBinder();
    Object jaxbElement =  (org.docx4j.wml.Document) binder.unmarshal(xmlNode);
           
    List<Object> list = XmlUtils.getJAXBNodesViaXPath(binder, jaxbElement,
        "//w:pict/v:oval", false );   
View Full Code Here

   
    String inputfilepath = System.getProperty("user.dir")
      + "/sample-docs/word/2010/2010-glow-then-AlternateContent.docx";       
   
   
    WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load(new java.io.File(inputfilepath));       

    // Since the JAXB binding stuff seems to remember
    // old artifacts, we'll first create a 'clean' object here
    // from something we've marshalled to. 
    org.w3c.dom.Document xmlNode = XmlUtils.marshaltoW3CDomDocument(
        wordMLPackage.getMainDocumentPart().getJaxbElement());       
    Binder<Node> binder = Context.jc.createBinder();
    Object jaxbElement =  (org.docx4j.wml.Document) binder.unmarshal(xmlNode);
           
    List<Object> list = XmlUtils.getJAXBNodesViaXPath(binder, jaxbElement,
        "//w:pict/v:oval", false );   
View Full Code Here

   
    String inputfilepath = System.getProperty("user.dir")
      + "/sample-docs/word/2010/2010-mcAlternateContent-in-header.docx";       
   
   
    WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage
        .load(new java.io.File(inputfilepath));

    List<SectionWrapper> sectionWrappers = wordMLPackage.getDocumentModel()
        .getSections();
    HeaderPart header = null;
    for (SectionWrapper sw : sectionWrappers) {
      HeaderFooterPolicy hfp = sw.getHeaderFooterPolicy();
      if (hfp.getDefaultHeader() != null) {
View Full Code Here

  public void testHeaderFlatOPC() throws Exception {
   
    String inputfilepath = System.getProperty("user.dir")
      + "/sample-docs/word/2010/2010-mcAlternateContent-in-header.xml";           
   
    WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load(new java.io.File(inputfilepath));       

    List<SectionWrapper> sectionWrappers = wordMLPackage.getDocumentModel()
        .getSections();
    HeaderPart header = null;
    for (SectionWrapper sw : sectionWrappers) {
      HeaderFooterPolicy hfp = sw.getHeaderFooterPolicy();
      if (hfp.getDefaultHeader() != null) {
View Full Code Here

  private final static int LENGTH = 1965;

  @Test
  public void testFile() throws Exception {
   
    WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
   
    File file = new File(System.getProperty("user.dir") + "/src/test/resources/images/greentick.png" );
        BinaryPartAbstractImage imagePart = BinaryPartAbstractImage.createImagePart(wordMLPackage, file);
        assertTrue(imagePart instanceof ImagePngPart);
       
View Full Code Here

  }

  @Test
  public void testByteArray() throws Exception {
   
    WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
   
    File file = new File(System.getProperty("user.dir") + "/src/test/resources/images/greentick.png" );
   
    // Convert file to byte array
    java.io.InputStream is = new java.io.FileInputStream(file );
View Full Code Here

  }
 
  @Test
  public void testFileUrl() throws Exception {
   
    WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
   
    // Construct file url
    File file = new File(System.getProperty("user.dir") + "/src/test/resources/images/greentick.png" );   
    URL url = file.toURI().toURL();
    System.out.println(url);
View Full Code Here

  }
 
  @Test
  public void testHttpUrl() throws Exception {
   
    WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
   
    // Construct file url
    URL url = new URL("http://upload.wikimedia.org/wikipedia/commons/thumb/a/ac/Green_tick.svg/75px-Green_tick.svg.png");
   
        BinaryPartAbstractImage imagePart = BinaryPartAbstractImage.createLinkedImagePart(wordMLPackage, url);
View Full Code Here

 
  @Test
  public void testExtensions() throws Exception {

   
    WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
   
    File file = new File(System.getProperty("user.dir") + "/src/test/resources/images/VENUS.BMP" );
   
    // Our utility method wants that as a byte array
    java.io.InputStream is = new java.io.FileInputStream(file );
        long length = file.length();   
        // You cannot create an array using a long type.
        // It needs to be an int type.
        if (length > Integer.MAX_VALUE) {
          System.out.println("File too large!!");
        }
        byte[] bytes = new byte[(int)length];
        int offset = 0;
        int numRead = 0;
        while (offset < bytes.length
               && (numRead=is.read(bytes, offset, bytes.length-offset)) >= 0) {
            offset += numRead;
        }
        // Ensure all the bytes have been read in
        if (offset < bytes.length) {
            System.out.println("Could not completely read file "+file.getName());
        }
        is.close();
       
        String filenameHint = null;
        String altText = null;
        int id1 = 0;
        int id2 = 1;
           
        org.docx4j.wml.P p = newImage( wordMLPackage, bytes,
            filenameHint, altText,
          id1, id2 );
       
    // Now add our p to the document
    wordMLPackage.getMainDocumentPart().addObject(p);

       
  }
View Full Code Here

TOP

Related Classes of org.docx4j.openpackaging.packages.WordprocessingMLPackage$FilterSettings

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.