Package org.docx4j.wml

Examples of org.docx4j.wml.Hdr


          Ftr ftr = ((FooterPart)part).getJaxbElement();
          finder.walkJAXBElements(ftr);
         
        } else if (part instanceof HeaderPart) {
         
          Hdr hdr = ((HeaderPart)part).getJaxbElement();
          finder.walkJAXBElements(hdr);
        }
      }
    }
   
View Full Code Here


          Ftr ftr = ((FooterPart)part).getJaxbElement();
          finder.walkJAXBElements(ftr);
         
        } else if (part instanceof HeaderPart) {
         
          Hdr hdr = ((HeaderPart)part).getJaxbElement();
          finder.walkJAXBElements(hdr);
        }
      }
    }
   
View Full Code Here

    return (currentSection.getHeaderFooterPolicy().getDefaultFooter() != null);
  }

  public static Node getFirstHeader(AbstractWmlConversionContext context) {
    ConversionSectionWrapper currentSection = context.getSections().getCurrentSection();
    Hdr hdr = (Hdr)currentSection.getHeaderFooterPolicy().getFirstHeader().getJaxbElement();
    return XmlUtils.marshaltoW3CDomDocument(hdr);
  }
View Full Code Here

    return XmlUtils.marshaltoW3CDomDocument(ftr);
  }

  public static Node getEvenHeader(AbstractWmlConversionContext context) {
    ConversionSectionWrapper currentSection = context.getSections().getCurrentSection();
    Hdr hdr = (Hdr)currentSection.getHeaderFooterPolicy().getEvenHeader().getJaxbElement();
    return XmlUtils.marshaltoW3CDomDocument(hdr);
  }
View Full Code Here

  }

  public static Node getDefaultHeader(AbstractWmlConversionContext context) {   
    ConversionSectionWrapper currentSection = context.getSections().getCurrentSection();
    Hdr hdr = currentSection.getHeaderFooterPolicy().getDefaultHeader().getJaxbElement();
    return XmlUtils.marshaltoW3CDomDocument(hdr);

  }
View Full Code Here

  }
 
  public static Hdr getHdr(WordprocessingMLPackage wordprocessingMLPackage,
      Part sourcePart) throws Exception {

    Hdr hdr = factory.createHdr();
   
    String openXML = "<w:p xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:w10=\"urn:schemas-microsoft-com:office:word\">"
                + "<w:pPr>"
                      + "<w:pStyle w:val=\"Header\"/>"

                +"</w:pPr>"
                + "<w:sdt>"
                +   "<w:sdtPr>"
                      + "<w:id w:val=\"-1589924921\"/>"

                      + "<w:lock w:val=\"sdtContentLocked\"/>"

                      + "<w:docPartObj>"
                            + "<w:docPartGallery w:val=\"Watermarks\"/>"

                            + "<w:docPartUnique/>"

                      +"</w:docPartObj>"

                +"</w:sdtPr>"

                + "<w:sdtEndPr/>"

                + "<w:sdtContent>"
                      + "<w:r>"
                            + "<w:rPr>"
                                  + "<w:noProof/>"

                                  + "<w:lang w:eastAsia=\"zh-TW\"/>"

                            +"</w:rPr>"

                            + "<w:pict>"
                                  + "<v:shapetype adj=\"10800\" coordsize=\"21600,21600\" id=\"_x0000_t136\" o:spt=\"136\" path=\"m@7,l@8,m@5,21600l@6,21600e\">"
                                        + "<v:formulas>"
                                              + "<v:f eqn=\"sum #0 0 10800\"/>"

                                              + "<v:f eqn=\"prod #0 2 1\"/>"

                                              + "<v:f eqn=\"sum 21600 0 @1\"/>"

                                              + "<v:f eqn=\"sum 0 0 @2\"/>"

                                              + "<v:f eqn=\"sum 21600 0 @3\"/>"

                                              + "<v:f eqn=\"if @0 @3 0\"/>"

                                              + "<v:f eqn=\"if @0 21600 @1\"/>"

                                              + "<v:f eqn=\"if @0 0 @2\"/>"

                                              + "<v:f eqn=\"if @0 @4 21600\"/>"

                                              + "<v:f eqn=\"mid @5 @6\"/>"

                                              + "<v:f eqn=\"mid @8 @5\"/>"

                                              + "<v:f eqn=\"mid @7 @8\"/>"

                                              + "<v:f eqn=\"mid @6 @7\"/>"

                                              + "<v:f eqn=\"sum @6 0 @5\"/>"

                                        +"</v:formulas>"

                                        + "<v:path o:connectangles=\"270,180,90,0\" o:connectlocs=\"@9,0;@10,10800;@11,21600;@12,10800\" o:connecttype=\"custom\" textpathok=\"t\"/>"

                                        + "<v:textpath fitshape=\"t\" on=\"t\"/>"

                                        + "<v:handles>"
                                              + "<v:h position=\"#0,bottomRight\" xrange=\"6629,14971\"/>"

                                        +"</v:handles>"

                                        + "<o:lock shapetype=\"t\" text=\"t\" v:ext=\"edit\"/>"

                                  +"</v:shapetype>"

                                  + "<v:shape fillcolor=\"silver\" id=\"PowerPlusWaterMarkObject357476642\" o:allowincell=\"f\" o:spid=\"_x0000_s2049\" stroked=\"f\" style=\"position:absolute;margin-left:0;margin-top:0;width:527.85pt;height:131.95pt;rotation:315;z-index:-251658752;mso-position-horizontal:center;mso-position-horizontal-relative:margin;mso-position-vertical:center;mso-position-vertical-relative:margin\" type=\"#_x0000_t136\">"
                                        + "<v:fill opacity=\".5\"/>"

                                        + "<v:textpath string=\"MY WATERMARK\" style=\"font-family:&quot;Calibri&quot;;font-size:1pt\"/>"

                                        + "<w10:wrap anchorx=\"margin\" anchory=\"margin\"/>"

                                  +"</v:shape>"

                            +"</w:pict>"

                      +"</w:r>"

                +"</w:sdtContent>"

          +"</w:sdt>"
          + "</w:p>";
     
    P p = (P)XmlUtils.unmarshalString(openXML);     

          hdr.getContent().add(p);
      return hdr;

    }
View Full Code Here

      public void onEndPage(PdfWriter writer, Document document) {
          try {
              Rectangle page = document.getPageSize();

              if (headerFooterPolicy.getHeader(writer.getPageNumber())!=null) {
                Hdr hdr = headerFooterPolicy.getHeader(writer.getPageNumber()).getJaxbElement();
                PdfPTable head = new PdfPTable(1); // num cols             
                // TODO - no cell borders
                traverseBlockLevelContent( hdr.getEGBlockLevelElts(), head);
                head.setTotalWidth(page.getWidth() - document.leftMargin() - document.rightMargin());
                head.writeSelectedRows(0, -1, document.leftMargin(), page.getHeight() - document.topMargin() + head.getTotalHeight(),
                    writer.getDirectContent());
              }
             
View Full Code Here

  }
 
  public static Hdr getHdr(WordprocessingMLPackage wordprocessingMLPackage,
      Part sourcePart) throws Exception {

    Hdr hdr = objectFactory.createHdr();
   
    File file = new File(System.getProperty("user.dir")
        + "/src/test/resources/images/greentick.png" );
    java.io.InputStream is = new java.io.FileInputStream(file );
   
    hdr.getContent().add(
        newImage(wordprocessingMLPackage,
            sourcePart,
            BufferUtil.getBytesFromInputStream(is),
            "filename", "alttext", 1, 2
            )
View Full Code Here

                      +"</w:pict>"
                  +"</w:r>"
              +"</w:p>"
          +"</w:hdr>";
   
      Hdr hdr = (Hdr)XmlUtils.unmarshalString(openXML);
     
      headerPart.setJaxbElement(hdr);

    }
View Full Code Here

TOP

Related Classes of org.docx4j.wml.Hdr

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.