iText layout.jar Source Code

layout.jar is a component in iText Java library to provide layout functionalities. iText Java library allows you to generate and manage PDF documents.

The Source Code files are provided together with the JAR file in the binary packge like You can download it at iText 7 Core Download site.

You can compile it to generate your JAR file, using layout.pom as the build configuration file.

The source code of layout-7.1.4.jar is provided below:




    This file is part of the iText (R) project.
    Copyright (c) 1998-2018 iText Group NV
    Authors: Bruno Lowagie, Paulo Soares, et al.

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License version 3
    as published by the Free Software Foundation with the addition of the
    following permission added to Section 15 as permitted in Section 7(a):

    This program is distributed in the hope that it will be useful, but
    WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
    See the GNU Affero General Public License for more details.
    You should have received a copy of the GNU Affero General Public License
    along with this program; if not, see or write to
    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
    Boston, MA, 02110-1301 USA, or download the license from the following URL:

    The interactive user interfaces in modified source and object code versions
    of this program must display Appropriate Legal Notices, as required under
    Section 5 of the GNU Affero General Public License.

    In accordance with Section 7(b) of the GNU Affero General Public License,
    a covered work must retain the producer line in every PDF that is created
    or manipulated using iText.

    You can be released from the requirements of the license by purchasing
    a commercial license. Buying such a license is mandatory as soon as you
    develop commercial activities involving the iText software without
    disclosing the source code of your own applications.
    These activities include: offering paid services to customers as an ASP,
    serving PDFs on the fly in a web application, shipping iText with a closed
    source product.

    For more information, please contact iText Software Corp. at this
package com.itextpdf.layout.renderer;

import com.itextpdf.kernel.pdf.PdfDocument;
import com.itextpdf.kernel.pdf.canvas.PdfCanvas;
import com.itextpdf.layout.IPropertyContainer;
import com.itextpdf.layout.layout.LayoutArea;
import com.itextpdf.layout.layout.LayoutContext;
import com.itextpdf.layout.layout.LayoutResult;

import java.util.List;

 * A renderer object is responsible for drawing a corresponding layout object on
 * a document or canvas. Every layout object has a renderer, by default one of
 * the corresponding type, e.g. you can ask an {@link com.itextpdf.layout.element.Image}
 * for its {@link ImageRenderer}.
 * Renderers are designed to be extensible, and custom implementations can be
 * seeded to layout objects (or their custom subclasses) at runtime.
public interface IRenderer extends IPropertyContainer {

     * Adds a child to the current renderer
     * @param renderer a child to be added
    void addChild(IRenderer renderer);

     * This method simulates positioning of the renderer, including all of its children, and returns
     * the {@link LayoutResult}, representing the layout result, including occupied area, status, i.e.
     * if there was enough place to fit the renderer subtree, etc.
     * {@link LayoutResult} can be extended to return custom layout results for custom elements, e.g.
     * {@link TextRenderer} uses {@link com.itextpdf.layout.layout.TextLayoutResult} as its result.
     * This method can be called standalone to learn how much area the renderer subtree needs, or can be called
     * before {@link #draw(DrawContext)}, to prepare the renderer to be flushed to the output stream.
     * @param layoutContext the description of layout area and any other additional information
     * @return result of the layout process
    LayoutResult layout(LayoutContext layoutContext);

     * Flushes the renderer subtree contents, i.e. draws itself on canvas,
     * adds necessary objects to the {@link PdfDocument} etc.
     * @param drawContext contains the {@link PdfDocument} to which the renderer subtree if flushed,
     *                    the {@link PdfCanvas} on which the renderer subtree is drawn and other additional parameters
     *                    needed to perform drawing
    void draw(DrawContext drawContext);

     * Gets the resultant occupied area after the last call to the {@link #layout(LayoutContext)} method.
     * @return {@link LayoutArea} instance
    LayoutArea getOccupiedArea();

     * Gets a property from this entity or one of its hierarchical parents.
     * If the property is not found, {@code defaultValue} will be returned.
     * @param <T1> the return type associated with the property
     * @param property the property to be retrieved
     * @param defaultValue a fallback value
     * @return the value of the given property
    <T1> T1 getProperty(int property, T1 defaultValue);

     * Explicitly sets this object as the child of another {@link IRenderer} in
     * the renderer hierarchy. Some implementations also use this method
     * internally to create a consistent hierarchy tree.
     * @param parent the object to place higher in the renderer hierarchy
     * @return by default, this object
    IRenderer setParent(IRenderer parent);

     * Gets the parent {@link IRenderer}.
     * @return direct parent {@link IRenderer renderer} of this instance
    IRenderer getParent();

     * Gets the model element associated with this renderer.
     * @return the model element, as a {@link IPropertyContainer container of properties}
    IPropertyContainer getModelElement();

     * Gets the child {@link IRenderer}s.
     * @return a list of direct child {@link IRenderer renderers} of this instance
    List<IRenderer> getChildRenderers();

     * Indicates whether this renderer is flushed or not, i.e. if {@link #draw(DrawContext)} has already
     * been called.
     * @return whether the renderer has been flushed
    boolean isFlushed();

     * Moves the renderer subtree by the specified offset. This method affects occupied area of the renderer.
     * @param dx the x-axis offset in points. Positive value will move the renderer subtree to the right.
     * @param dy the y-axis offset in points. Positive value will move the renderer subtree to the top.
    void move(float dx, float dy);

     * Gets a new instance of this class to be used as a next renderer, after this renderer is used, if
     * {@link #layout(LayoutContext)} is called more than once.
     * @return new renderer instance
    IRenderer getNextRenderer();



⇒ iText 5 itextpdf.jar Source Code

⇐ iText io.jar Source Code

⇑ Download and Install iText Java Library

⇑⇑ iText for PDF Generation

2021-07-03, 9225👍, 0💬