Package org.xhtmlrenderer.render

Examples of org.xhtmlrenderer.render.PageBox$RightMarginArea


            c.setExtraSpaceBottom(prevExtraBottom);
        }
    }
   
    private boolean isShouldMoveToNextPage(LayoutContext c) {
        PageBox page = c.getRootLayer().getFirstPage(c, this);
       
        if (getAbsY() + getHeight() < page.getBottom()) {
            return false;
        }
       
        for (Iterator i = getChildIterator(); i.hasNext(); ) {
            TableCellBox cell = (TableCellBox)i.next();
            int baseline = cell.calcBlockBaseline(c);
            if (baseline != BlockBox.NO_BASELINE && baseline < page.getBottom()) {
                return false;
            }
        }
       
        return true;
View Full Code Here


        int currentDelta = super.forcePageBreakBefore(c, pageBreakValue, pendingPageName);
       
        // additional calculations for collapsed borders.
        if (c.isPrint() && getStyle().isCollapseBorders()) {
            // get destination page for this row
            PageBox page = c.getRootLayer().getPage(c, getAbsY() + currentDelta);
            if (page!=null) {
               
                // calculate max spill from the collapsed top borders of each child
                int spill = 0;
                for (Iterator i = getChildIterator(); i.hasNext(); ) {
                    TableCellBox cell = (TableCellBox)i.next();
                    BorderPropertySet collapsed = cell.getCollapsedPaintingBorder();
                    if (collapsed != null) {
                        spill = Math.max(spill, (int)collapsed.top() / 2);
                    }
                }
   
                // be sure that the current start of the row is >= the start of the page
                int borderTop = getAbsY() + currentDelta + (int)getMargin(c).top() - spill;
                int rowDelta = page.getTop() - borderTop;
                if (rowDelta > 0) {
                    setY(getY() + rowDelta);
                    currentDelta += rowDelta;
                }
            }
View Full Code Here

                (float) pdfCorner.getX() + getDeviceLength(bounds.width), (float) pdfCorner.getY() + getDeviceLength(bounds.height));
        return result;
    }

    public com.lowagie.text.Rectangle createTargetArea(RenderingContext c, Box box) {
        PageBox current = c.getPage();
        boolean inCurrentPage = box.getAbsY() > current.getTop() && box.getAbsY() < current.getBottom();

        if (inCurrentPage || box.isContainedInMarginBox()) {
            return createLocalTargetArea(c, box);
        } else {
            Rectangle bounds = box.getContentAreaEdge(box.getAbsX(), box.getAbsY(), c);
            PageBox page = _root.getLayer().getPage(c, bounds.y);

            float bottom = getDeviceLength(page.getBottom() - (bounds.y + bounds.height)
                    + page.getMarginBorderPadding(c, CalculatedStyle.BOTTOM));
            float left = getDeviceLength(page.getMarginBorderPadding(c, CalculatedStyle.LEFT) + bounds.x);

            com.lowagie.text.Rectangle result = new com.lowagie.text.Rectangle(left, bottom, left + getDeviceLength(bounds.width), bottom
                    + getDeviceLength(bounds.height));
            return result;
        }
View Full Code Here

    }

    private PdfDestination createDestination(RenderingContext c, Box box) {
        PdfDestination result = null;

        PageBox page = _root.getLayer().getPage(c, getPageRefY(box));
        if (page != null) {
            int distanceFromTop = page.getMarginBorderPadding(c, CalculatedStyle.TOP);
            distanceFromTop += box.getAbsY() + box.getMargin(c).top() - page.getTop();
            result = new PdfDestination(PdfDestination.XYZ, 0, page.getHeight(c) / _dotsPerPoint - distanceFromTop / _dotsPerPoint, 0);
            result.addPage(_writer.getPageReference(_startPageNo + page.getPageNo() + 1));
        }

        return result;
    }
View Full Code Here

                size.x = 1;
                size.y = 1;
            }
            return new java.awt.Rectangle(size.x, size.y);
        } else {
            PageBox first = Layer.createPageBox(c, "first");
            return new java.awt.Rectangle(0, 0, first.getContentWidth(c), first.getContentHeight(c));
        }
    }
View Full Code Here

        String href = bookmark.getHRef();
        PdfDestination target = null;
        if (href.length() > 0 && href.charAt(0) == '#') {
            Box box = _sharedContext.getBoxById(href.substring(1));
            if (box != null) {
                PageBox page = root.getLayer().getPage(c, getPageRefY(box));
                int distanceFromTop = page.getMarginBorderPadding(c, CalculatedStyle.TOP);
                distanceFromTop += box.getAbsY() - page.getTop();
                target = new PdfDestination(PdfDestination.XYZ, 0, normalizeY(distanceFromTop / _dotsPerPoint), 0);
                target.addPage(_writer.getPageReference(_startPageNo + page.getPageNo() + 1));
            }
        }
        if (target == null) {
            target = _defaultDestination;
        }
View Full Code Here

        Shape working = out.getClip();

        List pages = root.getPages();
        c.setPageCount(pages.size());
        for (int i = 0; i < pages.size(); i++) {
            PageBox page = (PageBox) pages.get(i);
            c.setPage(i, page);

            java.awt.Rectangle overall = page.getScreenPaintingBounds(c, PAGE_PAINTING_CLEARANCE);
            overall.x -= 1;
            overall.y -= 1;
            overall.width += 1;
            overall.height += 1;

            java.awt.Rectangle bounds = new java.awt.Rectangle(overall);
            bounds.width += 1;
            bounds.height += 1;
            if (working.intersects(bounds)) {
                page.paintBackground(c, PAGE_PAINTING_CLEARANCE, Layer.PAGED_MODE_SCREEN);
                page.paintMarginAreas(c, PAGE_PAINTING_CLEARANCE, Layer.PAGED_MODE_SCREEN);
                page.paintBorder(c, PAGE_PAINTING_CLEARANCE, Layer.PAGED_MODE_SCREEN);

                Color old = gc.getForeground();
                gc.setForeground(gc.getDevice().getSystemColor(SWT.COLOR_BLACK));
                gc.drawRectangle(overall.x, overall.y, overall.width, overall.height);
                gc.setForeground(old);

                java.awt.Rectangle content = page.getPagedViewClippingBounds(c,
                        PAGE_PAINTING_CLEARANCE);
                out.clip(content);

                int left = PAGE_PAINTING_CLEARANCE
                        + page.getMarginBorderPadding(c, CalculatedStyle.LEFT);
                int top = page.getPaintingTop()
                        + page.getMarginBorderPadding(c, CalculatedStyle.TOP) - page.getTop();

                out.translate(left, top);
                root.paint(c);
                out.translate(-left, -top);
View Full Code Here

        return result;
    }

    private PagePosition calcPDFPagePosition(CssContext c, String id, Box box) {
        PageBox page = _root.getLayer().getLastPage(c, box);
        if (page == null) {
            return null;
        }

        float x = box.getAbsX() + page.getMarginBorderPadding(c, CalculatedStyle.LEFT);
        float y = (page.getBottom() - (box.getAbsY() + box.getHeight())) + page.getMarginBorderPadding(c, CalculatedStyle.BOTTOM);
        x /= _dotsPerPoint;
        y /= _dotsPerPoint;

        PagePosition result = new PagePosition();
        result.setId(id);
        result.setPageNo(page.getPageNo());
        result.setX(x);
        result.setY(y);
        result.setWidth(box.getEffectiveWidth() / _dotsPerPoint);
        result.setHeight(box.getHeight() / _dotsPerPoint);
View Full Code Here

            try {
                long start = System.currentTimeMillis();

                rootBox = BoxBuilder.createRootBox(layout, doc);

                PageBox first = Layer.createPageBox(layout, "first");
                rootBox.setContainingBlock(new ViewportBox(new Rectangle(0, 0,
                    first.getContentWidth(layout), first
                        .getContentHeight(layout))));
                rootBox.layout(layout);

                long end = System.currentTimeMillis();
                XRLog.layout(Level.INFO, "Layout took " + (end - start) + "ms");
            } catch (Throwable e) {
                XRLog.exception(e.getMessage(), e);
                return;
            }

            Layer root = rootBox.getLayer();
            Dimension intrinsic_size = root.getPaintingDimension(layout);
            root.trimEmptyPages(layout, intrinsic_size.height);
            root.assignPagePaintingPositions(layout, Layer.PAGED_MODE_PRINT);

            // RENDER
            c = newRenderingContext(gc);
            List pages = root.getPages();
            c.setPageCount(pages.size());
            if (startPage < 0) {
                startPage = 0;
            } else if (startPage >= pages.size()) {
                startPage = pages.size() - 1;
            }
            if (endPage < 0 || endPage >= pages.size()) {
                endPage = pages.size() - 1;
            }

            Shape working = c.getOutputDevice().getClip();

            for (int i = startPage; i <= endPage; i++) {
                PageBox page = (PageBox) pages.get(i);
                c.setPage(i, page);

                if (!_printer.startPage()) {
                    return;
                }
               
                page.paintBackground(c, 0, Layer.PAGED_MODE_PRINT);
                page.paintMarginAreas(c, 0, Layer.PAGED_MODE_PRINT);
                page.paintBorder(c, 0, Layer.PAGED_MODE_PRINT);

                Rectangle content = page.getPrintClippingBounds(c);
                c.getOutputDevice().clip(content);

                int top = -page.getPaintingTop()
                        + page.getMarginBorderPadding(c, CalculatedStyle.TOP);
                int left = page.getMarginBorderPadding(c, CalculatedStyle.LEFT);

                c.getOutputDevice().translate(left, top);
                root.paint(c);
                c.getOutputDevice().translate(-left, -top);
View Full Code Here

        if (running) {
            int headerHeight = layoutRunningHeader(c);
            int footerHeight = layoutRunningFooter(c);
            int spacingHeight = footerHeight == 0 ? 0 : getStyle().getBorderVSpacing(c);

            PageBox first = c.getRootLayer().getFirstPage(c, this);
            if (getAbsY() + getTy() + headerHeight + footerHeight + spacingHeight > first.getBottom()) {
                // XXX Performance problem here.  This forces the table
                // to move to the next page (which we want), but the initial
                // table layout run still completes (which we don't)
                setNeedPageClear(true);
            }
View Full Code Here

TOP

Related Classes of org.xhtmlrenderer.render.PageBox$RightMarginArea

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.