=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/PDFUtils.java' --- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/PDFUtils.java 2011-02-23 14:27:49 +0000 +++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/PDFUtils.java 2011-03-30 07:47:00 +0000 @@ -235,6 +235,16 @@ return getCell( text, 1, getItalicFont( 9 ), ALIGN_LEFT ); } + public static PdfPCell resetPaddings( PdfPCell cell, float top, float bottom, float left, float right ) + { + cell.setPaddingTop( top ); + cell.setPaddingBottom( bottom ); + cell.setPaddingLeft( left ); + cell.setPaddingRight( right ); + + return cell; + } + /** * Creates an empty cell. * === modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/result/GridPdfResult.java' --- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/result/GridPdfResult.java 2011-03-14 20:23:43 +0000 +++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/result/GridPdfResult.java 2011-03-30 07:47:00 +0000 @@ -27,6 +27,16 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import static org.hisp.dhis.system.util.PDFUtils.addTableToDocument; +import static org.hisp.dhis.system.util.PDFUtils.closeDocument; +import static org.hisp.dhis.system.util.PDFUtils.getEmptyCell; +import static org.hisp.dhis.system.util.PDFUtils.getItalicCell; +import static org.hisp.dhis.system.util.PDFUtils.getSubtitleCell; +import static org.hisp.dhis.system.util.PDFUtils.getTextCell; +import static org.hisp.dhis.system.util.PDFUtils.getTitleCell; +import static org.hisp.dhis.system.util.PDFUtils.openDocument; +import static org.hisp.dhis.system.util.PDFUtils.resetPaddings; + import java.io.OutputStream; import java.util.List; @@ -44,8 +54,6 @@ import com.opensymphony.xwork2.ActionInvocation; import com.opensymphony.xwork2.Result; -import static org.hisp.dhis.system.util.PDFUtils.*; - /** * @author Lars Helge Overland */ @@ -59,7 +67,7 @@ // ------------------------------------------------------------------------- private Grid grid; - + public void setGrid( Grid grid ) { this.grid = grid; @@ -78,8 +86,8 @@ // --------------------------------------------------------------------- Grid _grid = (Grid) invocation.getStack().findValue( "grid" ); - - grid = _grid != null ? _grid : grid; + + grid = _grid != null ? _grid : grid; // --------------------------------------------------------------------- // Configure response @@ -89,33 +97,34 @@ OutputStream out = response.getOutputStream(); - String filename = CodecUtils.filenameEncode( StringUtils.defaultIfEmpty( grid.getTitle(), DEFAULT_FILENAME ) ) + ".pdf"; - + String filename = CodecUtils.filenameEncode( StringUtils.defaultIfEmpty( grid.getTitle(), DEFAULT_FILENAME ) ) + + ".pdf"; + ContextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_PDF, true, filename, false ); // --------------------------------------------------------------------- // Write PDF to output stream // --------------------------------------------------------------------- - + Document document = openDocument( out ); - + PdfPTable table = new PdfPTable( grid.getVisibleWidth() ); - + table.setHeaderRows( 1 ); table.setWidthPercentage( 100f ); + table.setKeepTogether( false ); - table.addCell( getTitleCell( grid.getTitle(), grid.getVisibleWidth() ) ); - table.addCell( getEmptyCell( grid.getVisibleWidth(), 30 ) ); + table.addCell( resetPaddings( getTitleCell( grid.getTitle(), grid.getVisibleWidth() ), 0, 45, 0, 0 ) ); table.addCell( getSubtitleCell( grid.getSubtitle(), grid.getVisibleWidth() ) ); table.addCell( getEmptyCell( grid.getVisibleWidth(), 30 ) ); - + for ( GridHeader header : grid.getVisibleHeaders() ) { table.addCell( getItalicCell( header.getName() ) ); } table.addCell( getEmptyCell( grid.getVisibleWidth(), 10 ) ); - + for ( List row : grid.getVisibleRows() ) { for ( Object col : row )