Example usage for com.itextpdf.text.pdf PdfContentByte getPdfDocument

List of usage examples for com.itextpdf.text.pdf PdfContentByte getPdfDocument

Introduction

In this page you can find the example usage for com.itextpdf.text.pdf PdfContentByte getPdfDocument.

Prototype

public PdfDocument getPdfDocument() 

Source Link

Document

Gets the PdfDocument in use by this object.

Usage

From source file:org.javad.pdf.util.PdfUtil.java

License:Apache License

public static float findMaximumWidth(IContentGenerator generator, PdfContentByte content) {
    float width = 0.0f;
    try {//  w ww  .j  a  v  a  2  s .  co  m
        Document d = new Document(content.getPdfDocument().getPageSize());
        PdfWriter writer = PdfWriter.getInstance(d, new ByteArrayOutputStream());
        d.open();
        PdfContentByte c = writer.getDirectContent();
        OutputBounds bounds = generator.generate(c);
        width = bounds.width;
        d.newPage();
        d.close();
    } catch (Throwable e) {
        e.printStackTrace();
    }
    return width;
}