List of usage examples for com.itextpdf.text.pdf PdfContentByte getPdfDocument
public PdfDocument getPdfDocument()
PdfDocument
in use by this object. 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; }