Package org.xhtmlrenderer.render

Examples of org.xhtmlrenderer.render.Box


        if (verbose()) {
            System.out.println("Comparing " + source.getName());
        }
        stat.checking(source);
        BoxRenderer renderer = new BoxRenderer(source, width);
        Box box;
        try {
            box = renderer.render();
        } catch (Exception e) {
            stat.failedToRender(e);
            storeFailed(failedDirectory, source);
            if (verbose()) {
                System.err.println("Could not render input file, skipping: " + source + " err: " + e.getMessage());
            }
            return;
        }
        LayoutContext layoutContext = renderer.getLayoutContext();
        String inputFileName = source.getName();
        String refRendered = trimTrailingLS(readReference(referenceDir, inputFileName, Regress.RENDER_SFX));
        String rendered = trimTrailingLS(box.dump(layoutContext, "", Box.DUMP_RENDER));
        if (!match(refRendered, rendered, stat)) {
            storeFailed(failedDirectory, new File(referenceDir, inputFileName), Regress.RENDER_SFX, rendered);
        }

        final String refLaidOut = trimTrailingLS(readReference(referenceDir, inputFileName, Regress.LAYOUT_SFX));
        final String laidOut = trimTrailingLS(box.dump(layoutContext, "", Box.DUMP_LAYOUT));
        if (!match(refLaidOut, laidOut, stat)) {
            storeFailed(failedDirectory, new File(referenceDir, inputFileName), Regress.LAYOUT_SFX, laidOut);
        }
    }
View Full Code Here


        processLink(c, box);
    }

    private com.itextpdf.text.Rectangle calcTotalLinkArea(RenderingContext c, Box box) {
        Box current = box;
        while (true) {
            Box prev = current.getPreviousSibling();
            if (prev == null || prev.getElement() != box.getElement()) {
                break;
            }

            current = prev;
        }
View Full Code Here

            NamespaceHandler handler = _sharedContext.getNamespaceHandler();
            String uri = handler.getLinkUri(elem);
            if (uri != null) {
                if (uri.length() > 1 && uri.charAt(0) == '#') {
                    String anchor = uri.substring(1);
                    Box target = _sharedContext.getBoxById(anchor);
                    if (target != null) {
                        PdfDestination dest = createDestination(c, target);

                        PdfAction action = new PdfAction();
                        if (!"".equals(handler.getAttributeValue(elem, "onclick"))) {
View Full Code Here

    private void writeBookmark(RenderingContext c, Box root, PdfOutline parent, Bookmark bookmark) {
        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) {
View Full Code Here

        List result = new ArrayList();
        for (Iterator i = idMap.entrySet().iterator(); i.hasNext();) {
            Map.Entry entry = (Entry) i.next();
            String id = (String) entry.getKey();
            if (pattern.matcher(id).find()) {
                Box box = (Box) entry.getValue();
                PagePosition pos = calcPDFPagePosition(c, id, box);
                if (pos != null) {
                    result.add(pos);
                }
            }
View Full Code Here

    private void createField(RenderingContext c,
            ITextOutputDevice outputDevice, PdfContentByte cb,
            PdfWriter writer, PdfFormField group,
            RadioButtonFormField fieldElem, RadioButtonFormField checked) {
        Box box = fieldElem.getBox();
       
        Element e = box.getElement();
        String onValue = getValue(e);
       
        float width = outputDevice.getDeviceLength(fieldElem.getWidth());
        float height = outputDevice.getDeviceLength(fieldElem.getHeight());

        PdfFormField field = PdfFormField.createEmpty(writer);

        FSColor color = box.getStyle().getColor();
        FSColor darker = box.getEffBackgroundColor(c).darkenColor();
        createAppearances(cb, field, onValue, width, height, true, color, darker);
        createAppearances(cb, field, onValue, width, height, false, color, darker);

        field.setWidget(
                outputDevice.createTargetArea(c, box),
                PdfAnnotation.HIGHLIGHT_INVERT);
       
        // XXX createTargetArea already looks up the page, but hopefully a document
        // won't have enough radio buttons to matter
        Rectangle bounds = box.getContentAreaEdge(box.getAbsX(), box.getAbsY(), c);
        PageBox page = c.getRootLayer().getPage(c, bounds.y);
        field.setPlaceInPage(page.getPageNo()+1);

        field.setBorderStyle(new PdfBorderDictionary(0.0f, 0));
View Full Code Here

    private void printTree(Box box, String tab) {
        XRLog.layout(Level.FINEST, tab + "Box = " + box);
        Iterator it = box.getChildIterator();
        while (it.hasNext()) {
            Box bx = (Box) it.next();
            printTree(bx, tab + " ");
        }
    }
View Full Code Here

     */
    protected void setDocumentRelative(String filename) {
        String url = getSharedContext().getUac().resolveURI(filename);
        if (isAnchorInCurrentDocument(filename)) {
            String id = getAnchorId(filename);
            Box box = getSharedContext().getBoxById(id);
            if (box != null) {
                Point pt;
                if (box.getStyle().isInline()) {
                    pt = new Point(box.getAbsX(), box.getAbsY());
                } else {
                    RectPropertySet margin = box.getMargin(getLayoutContext());
                    pt = new Point(
                            box.getAbsX() + (int)margin.left(),
                            box.getAbsY() + (int)margin.top());
                }
                scrollTo(pt);
                return;
            }
        }
View Full Code Here

            };
            NodeIterator nodeIterator = this.docTraversal.createNodeIterator(range
                    .getCommonAncestorContainer(), NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT
                    | NodeFilter.SHOW_CDATA_SECTION, f, false);
            Box box;
            boolean lastNodeWasBox = false;
            for (Node n = nodeIterator.nextNode(); n != null; n = nodeIterator.nextNode()) {
                if (n.getNodeType() == Node.ELEMENT_NODE) {
                    box = getBoxForElement((Element) n);
                    if (box instanceof BlockBox && !lastNodeWasBox) {
View Full Code Here

        }
        return buf.toString();
    }

    private Box getElementContainerBox(InlineText t) {
        Box b = t.getParent();
        while (b.getElement() == null) {
            b = b.getParent();
        }
        return b;
    }
View Full Code Here

TOP

Related Classes of org.xhtmlrenderer.render.Box

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.