Package org.docx4j.model.structure

Examples of org.docx4j.model.structure.PageDimensions


      int id1, int id2, boolean link) throws Exception {
       
        WordprocessingMLPackage wmlPackage = ((WordprocessingMLPackage) this.getPackage());
   
    List<SectionWrapper> sections = wmlPackage.getDocumentModel().getSections();
        PageDimensions page = sections.get(sections.size() - 1).getPageDimensions();
   
    CxCy cxcy = CxCy.scale(imageInfo, page);
        return createImageInline(filenameHint, altText,
                id1, id2, cxcy.getCx(), cxcy.getCy(), link);
View Full Code Here


       
        String landscapeString = Docx4jProperties.getProperties().getProperty("docx4j.PageOrientationLandscape", "false");
        boolean landscape= Boolean.parseBoolean(landscapeString);
        log.info("Landscape orientation: " + landscape);
       
        PageDimensions page = new PageDimensions();
        page.setPgSize(PageSizePaper.valueOf(papersize), landscape);
       
        sectPr = Context.getWmlObjectFactory().createSectPr();
        sectPr.setPgSzpage.getPgSz() );
        sectPr.setPgMar( page.getPgMar() );       
       }
      
       // <w:pgNumType w:start="1"/>
       CTPageNumber pageNumber = sectPr.getPgNumType();
       if (pageNumber==null) {
View Full Code Here

          String simplePageMasterName = spm.getMasterName()// eg s1-first page
         
          // We'll need the corresponding ConversionSectionWrapper
          int index = -1 + Integer.parseInt(
              simplePageMasterName.substring(1, simplePageMasterName.indexOf("-")));
          PageDimensions page = null;
          if (sections.get(index)==null) {
            log.error("Couldn't find section " + index + " from " + simplePageMasterName);
          } else {
            page = sections.get(index).getPageDimensions();
          }
         
          // Region before
          if (spm.getRegionBefore()!=null) {
            Integer hBpdaMilliPts = headerBpda.get(simplePageMasterName);
            if (hBpdaMilliPts==null) {
              // No headerBpda for s1-default
              log.error("No headerBpda for " + simplePageMasterName);
              // You need to debug to find out why
             
            } else {
                float hBpdaPts = hBpdaMilliPts/1000;
              spm.getRegionBefore().setExtent(hBpdaPts+"pt");
              spm.getRegionBody().setMarginTop(hBpdaPts+"pt");
             
              // If the top margin in Word > what we have, then pad with margin top
              float totalHeight = (page.getHeaderMargin()/20 ) // twips to points
                        + hBpdaPts;
             
              float extraMargin = (page.getPgMar().getTop().intValue()/20) - totalHeight; 
             
              if (extraMargin>0) {
                float required = (page.getPgMar().getTop().intValue()-page.getHeaderMargin())/20;
                spm.getRegionBody().setMarginTop(required+"pt");             
              } // otherwise, we've expanded to the extent of the header already
            }
          }
         
          // Region after
          if (spm.getRegionAfter()!=null) {
            Integer fBpdaMilliPts = footerBpda.get(simplePageMasterName);
            if (fBpdaMilliPts==null) {
              log.error("No footerBpda for " + simplePageMasterName);
             
            } else {           
              float fBpdaPts = fBpdaMilliPts/1000;
              spm.getRegionAfter().setExtent(fBpdaPts+"pt");
              spm.getRegionBody().setMarginBottom(fBpdaPts+"pt");
             
              // If the bottom margin in Word > what we have, then pad with margin bottom
              float totalHeight = (page.getFooterMargin()/20 ) // twips to points
                        + fBpdaPts;
             
              float extraMargin = (page.getPgMar().getBottom().intValue()/20) - totalHeight; 
             
              if (extraMargin>0) {
                float required = (page.getPgMar().getBottom().intValue()-page.getFooterMargin())/20;
                spm.getRegionBody().setMarginBottom(required+"pt");             
              } // otherwise, we've expanded to the extent of the footer already
           
            }
          }         
View Full Code Here

    org.docx4j.wml.Document wmlDocumentEl = factory.createDocument();
   
    wmlDocumentEl.setBody(body);
   
    // Create a basic sectPr using our Page model
    PageDimensions page = new PageDimensions();
    page.setPgSize(sz, landscape);
   
    SectPr sectPr = factory.createSectPr();
    body.setSectPr(sectPr);
    sectPr.setPgSzpage.getPgSz() );
    sectPr.setPgMar( page.getPgMar() );
       
    // Put the content in the part
    wordDocumentPart.setJaxbElement(wmlDocumentEl);
           
    // Add the main document part to the package relationships
View Full Code Here

    String dataRelId = wordMLPackage.getMainDocumentPart().addTargetPart(data).getId();
    String colorsRelId = wordMLPackage.getMainDocumentPart().addTargetPart(colors).getId();
    String styleRelId = wordMLPackage.getMainDocumentPart().addTargetPart(style).getId();

    // Occupy entire page, less margins
    PageDimensions pd = new PageDimensions();
    pd.setPgSize(sz, landscape );
    PgSz pgSz = pd.getPgSz();
    pd.setMargins(margins);
    String cx =  ""+UnitsOfMeasurement.twipToEMU(pgSz.getW().intValue()
        - (pd.getPgMar().getLeft().intValue()+pd.getPgMar().getRight().intValue() ) )//"5486400";
    String cy = ""+UnitsOfMeasurement.twipToEMU(pgSz.getH().intValue()
        - (pd.getPgMar().getTop().intValue()+pd.getPgMar().getBottom().intValue() ));   //"3200400";
   
    // Now use it in the docx
    wordMLPackage.getMainDocumentPart().addObject(
        createSmartArt( layoutRelId,  dataRelId, colorsRelId,  styleRelId, cx, cy));
   
View Full Code Here

//    String height = props.get("height");

   
    // How to get current page width??
    ConversionSectionWrapper csw = context.getSections().getCurrentSection();
    PageDimensions pageDimensions = csw.getPageDimensions();
   
    // pgSz.getW().intValue() - (pgMar.getLeft().intValue() + pgMar.getRight().intValue());
    int writableWidthTwips = pageDimensions.getWritableWidthTwips();
    float writableWidthPts = writableWidthTwips/20;
    int writableHeightTwips = pageDimensions.getWritableHeightTwips();
    float writableHeightPts = writableHeightTwips/20;

    // TODO - avoid reference to FORenderer here! See 
    FORenderer foRenderer  = ((FOSettings)context.getConversionSettings()).getCustomFoRenderer();
    log.debug(foRenderer.getClass().getName());
View Full Code Here

TOP

Related Classes of org.docx4j.model.structure.PageDimensions

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.