/** * Creates a document. * * @param outputStream The output stream to write the document content. * @return A Document. */ public static Document openDocument( OutputStream outputStream ) { return openDocument( outputStream, PageSize.A4 ); }
public static PdfPCell getTitleCell( String text, int colspan ) { return getCell( text, colspan, getBoldFont( 16 ), ALIGN_CENTER ); }
public static PdfPCell getSubtitleCell( String text, int colspan ) { return getCell( text, colspan, getItalicFont( 12 ), ALIGN_CENTER ); }
table.setSpacingAfter( spacing ); table.addCell( resetPaddings( getTitleCell( grid.getTitle(), grid.getVisibleWidth() ), 0, 30, 0, 0 ) ); table.addCell( getSubtitleCell( grid.getSubtitle(), grid.getVisibleWidth() ) ); table.addCell( getEmptyCell( grid.getVisibleWidth(), 30 ) ); table.addCell( getItalicCell( header.getColumn() ) ); table.addCell( getEmptyCell( grid.getVisibleWidth(), 10 ) ); table.addCell( getTextCell( col ) ); addTableToDocument( document, table );
@Override protected void startWriteRootNode( RootNode rootNode ) throws Exception { for ( Node child : rootNode.getChildren() ) { if ( child.isCollection() ) { PdfPTable table = PDFUtils.getPdfPTable( true, 0.25f, 0.75f ); boolean haveContent = false; for ( Node node : child.getChildren() ) { for ( Node property : node.getChildren() ) { if ( property.isSimple() ) { table.addCell( PDFUtils.getItalicCell( property.getName() ) ); table.addCell( PDFUtils.getTextCell( getValue( (SimpleNode) property ) ) ); haveContent = true; } } if ( haveContent ) { table.addCell( PDFUtils.getEmptyCell( 2, 15 ) ); haveContent = false; } } document.add( table ); } } }
private static void addPdfTimestamp( Document document, boolean paddingTop ) { PdfPTable table = new PdfPTable(1); table.addCell( getEmptyCell( 1, ( paddingTop ? 30 : 0 ) ) ); table.addCell( getTextCell( getGeneratedString() ) ); addTableToDocument( document, table ); }
/** * Writes a PDF representation of the given Grid to the given OutputStream. */ public static void toPdf( Grid grid, OutputStream out ) { if ( isNonEmptyGrid( grid ) ) { Document document = openDocument( out ); toPdfInternal( grid, document, 0F ); addPdfTimestamp( document, true ); closeDocument( document ); } }
public static Font getBoldFont( float size ) { return getFont( "ubuntu-bold.ttf", size ); }
/** * Writes a PDF representation of the given list of Grids to the given OutputStream. */ public static void toPdf( List<Grid> grids, OutputStream out ) { if ( hasNonEmptyGrid( grids ) ) { Document document = openDocument( out ); for ( Grid grid : grids ) { toPdfInternal( grid, document, 40F ); } addPdfTimestamp( document, false ); closeDocument( document ); } }
public static PdfPCell getItalicCell( String text ) { return getCell( text, 1, getItalicFont( 9 ), ALIGN_LEFT ); }
public static Font getItalicFont( float size ) { return getFont( "ubuntu-italic.ttf", size ); }
@Override protected void startSerialize( RootNode rootNode, OutputStream outputStream ) throws Exception { document = PDFUtils.openDocument( outputStream ); }
public static Font getFont( float size ) { return getFont( "ubuntu.ttf", size ); }