dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #11347
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3214: Pdf export result - Expanding the space between the header/subheader and the table/text body on t...
------------------------------------------------------------
revno: 3214
committer: Hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2011-03-30 14:47:00 +0700
message:
Pdf export result - Expanding the space between the header/subheader and the table/text body on the next page.
modified:
dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/PDFUtils.java
dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/result/GridPdfResult.java
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== 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<Object> row : grid.getVisibleRows() )
{
for ( Object col : row )