Example usage for com.lowagie.text.pdf PdfGraphics2D getContent

List of usage examples for com.lowagie.text.pdf PdfGraphics2D getContent

Introduction

In this page you can find the example usage for com.lowagie.text.pdf PdfGraphics2D getContent.

Prototype

public PdfContentByte getContent() 

Source Link

Usage

From source file:org.geoserver.wms.map.PDFMaxSizeEnforcer.java

License:Open Source License

/**
 * Builds a new max errors enforcer. If maxErrors is not positive the enforcer will do nothing
 * //from  w  ww  . jav a 2 s . co m
 * @param renderer
 * @param maxErrors
 */
public PDFMaxSizeEnforcer(final GTRenderer renderer, final PdfGraphics2D graphics, final int maxSize) {
    this.maxSize = maxSize;
    this.pdfBytes = graphics.getContent().getInternalBuffer();

    if (maxSize > 0) {
        renderer.addRenderListener(new RenderListener() {

            public void featureRenderer(SimpleFeature feature) {
                if (pdfBytes.size() > maxSize) {
                    renderer.stopRendering();
                }
            }

            public void errorOccurred(Exception e) {
            }
        });
    }
}