Guest User

Untitled

a guest
Jul 19th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.96 KB | None | 0 0
  1. <?php
  2.  
  3. java_require( realpath( dirname( __FILE__ ) . "/test.jar" ) );
  4. java_require( realpath( dirname( __FILE__ ) . "/commons-beanutils-1.8.0.jar" ) );
  5. java_require( realpath( dirname( __FILE__ ) . "/commons-collections-3.2.1.jar" ) );
  6. java_require( realpath( dirname( __FILE__ ) . "/commons-digester-1.7.jar" ) );
  7. java_require( realpath( dirname( __FILE__ ) . "/commons-logging-1.1.jar" ) );
  8. java_require( realpath( dirname( __FILE__ ) . "/iText-2.1.0.jar" ) );
  9. java_require( realpath( dirname( __FILE__ ) . "/groovy-all-1.5.5.jar" ) );
  10. java_require( realpath( dirname( __FILE__ ) . "/jasperreports-3.6.2.jar" ) );
  11. java_require( realpath( dirname( __FILE__ ) . "/jasperreports-chart-themes-3.6.2.jar" ) );
  12. java_require( realpath( dirname( __FILE__ ) . "/jasperreports-extensions-3.5.3.jar" ) );
  13. java_require( realpath( dirname( __FILE__ ) . "/jasperreports-fonts-3.6.1.jar" ) );
  14.  
  15. /*
  16. java_require( realpath( dirname( __FILE__ ) . "/jasperreports-chart-themes-3.6.2.jar" ) );
  17. java_require( realpath( dirname( __FILE__ ) . "/jasperreports-extensions-3.5.3.jar" ) );
  18. java_require( realpath( dirname( __FILE__ ) . "/jasperreports-fonts-3.6.1.jar" ) );
  19. java_require( realpath( dirname( __FILE__ ) . "/iText-2.1.0.jar" ) );
  20. java_require( realpath( dirname( __FILE__ ) . "/iTextAsian.jar" ) );
  21. java_require( realpath( dirname( __FILE__ ) . "/commons-beanutils-1.8.0.jar" ) );
  22. java_require( realpath( dirname( __FILE__ ) . "/commons-collections-3.2.1.jar" ) );
  23. java_require( realpath( dirname( __FILE__ ) . "/commons-dbcp-1.2.2.jar" ) );
  24. java_require( realpath( dirname( __FILE__ ) . "/commons-digester-1.7.jar" ) );
  25. java_require( realpath( dirname( __FILE__ ) . "/commons-javaflow-20060411.jar" ) );
  26. java_require( realpath( dirname( __FILE__ ) . "/commons-logging-1.1.jar" ) );
  27. java_require( realpath( dirname( __FILE__ ) . "/commons-math-1.0.jar" ) );
  28. java_require( realpath( dirname( __FILE__ ) . "/commons-pool-1.3.jar" ) );
  29. java_require( realpath( dirname( __FILE__ ) . "/commons-vfs-1.0.jar" ) );
  30. */
  31. //try
  32. //{
  33. // $system = new Java( "java.lang.System" );
  34. // $classPath = implode( PATH_SEPARATOR, array(
  35. // ".",
  36. // "/usr/local/zend/bin/javamw.jar",
  37. // realpath( dirname( __FILE__ ) )
  38. // ) );
  39. // $system->setProperty( "java.class.path", $classPath );
  40. //echo "<hr>cp: ";
  41. //var_dump($system->getProperty( "java.class.path" ));
  42. //exit();
  43. $filename = implode( DIRECTORY_SEPARATOR, array(
  44. dirname( __FILE__ ),
  45. "report1.pdf"
  46. ) );
  47. $xml = realpath( dirname( __FILE__ ) . "/report1.jrxml" );
  48. $report = realpath( dirname( __FILE__ ) . "/report1.jasper" );
  49.  
  50. $vector = new Java( "java.util.Vector" );
  51.  
  52. foreach ( range( 1, 100 ) AS $number )
  53. {
  54. $bean = new Java( "org.vesifront.BeanTest" );
  55. $bean->setTestFive( rand() );
  56. $bean->setTestFour( rand() );
  57. $bean->setTestOne( rand() );
  58. $bean->setTestThree( rand() );
  59. $bean->setTestTwo( rand() );
  60.  
  61. $vector->add( $bean );
  62. }
  63.  
  64. $parameters = new Java( "java.util.HashMap" );
  65. $parameters->put( "tales1", "huh I'm a param! *geez*" );
  66. /*
  67. $jasperCompileManager = new Java( "net.sf.jasperreports.engine.JasperCompileManager" );
  68. echo "<hr>cm: ";
  69. var_dump($jasperCompileManager);
  70. //exit();
  71. $report = $jasperCompileManager->compileReport( $xml );
  72. echo "<hr>c: ";
  73. var_dump($report);
  74. exit();
  75. */
  76. // $report = new Java( "java.lang.String", $report );
  77. //echo "<hr>r: ";
  78. //var_dump($report);
  79. // $emptyDataSource = new Java( "net.sf.jasperreports.engine.JREmptyDataSource" );
  80. $jasperFillManager = new Java( "net.sf.jasperreports.engine.JasperFillManager" );
  81. //echo "<hr>j: ";
  82. //var_dump($jasperFillManager);
  83. //exit();
  84.  
  85. $beansCollection = new Java( "net.sf.jasperreports.engine.data.JRBeanCollectionDataSource", $vector );
  86. //echo "<hr>bc: ";
  87. //var_dump($beansCollection);
  88. $print = $jasperFillManager->fillReport(
  89. $report,
  90. $parameters,
  91. $beansCollection
  92. );
  93. // $print = $jasperFillManager->fillReport( $report, $parameters, $emptyDataSource );
  94. // $print = $jasperFillManager->fillReport( $report, $parameters );
  95.  
  96. $jasperExportManager = new Java( "net.sf.jasperreports.engine.JasperExportManager" );
  97. $jasperExportManager->exportReportToPdfFile( $print, $filename );
  98. /*
  99. if ( file_exists( $filename ) )
  100. {
  101. header( "Content-disposition: attachment; filename='report1.pdf'");
  102. header( "Content-Type: application/pdf" );
  103. header( "Content-Transfer-Encoding: binary" );
  104. header( "Content-Length: ". @filesize( $filename ) );
  105. header( "Pragma: no-cache" );
  106. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  107. header( "Expires: 0" );
  108. set_time_limit( 0 );
  109. @readfile( $filename ) || die( "Can't read PDF file" );
  110. }
  111. else
  112. {
  113. die( "No PDF file" );
  114. }
  115. */
  116. //}
  117. //catch ( JavaException $exception )
  118. //{
  119. // throw new Exception( "Java Exception, ({$exception->getCause()})" );
  120. //}
Add Comment
Please, Sign In to add comment