Jump to content
Changes to the Jaspersoft community edition download ×

differences when PDF exporting with PHP


Recommended Posts

By: eric - greatmaster

differences when PDF exporting with PHP

2003-12-01 01:34

Hi,

 

i use jasperreport to generate PDF over our DATABASES. I want to use it in our PHP web site.

 

It works fine when i generate it with JAVA. But when i call the same method trough the PHP i hav some differences like :

- EMPTY FIELDS

- SOME LINES ARE NOT AS WELL ALIGNED

 

Is there anything to do to avoid that ?

 

I have a couple of PDF, one generated in pure JAVA and the other generated through PHP, but using the SAME METHOD. They have different size and contents (some of them).

 

You should see this method above:

<code>

import dori.jasper.engine.*;

import dori.jasper.view.*;

import it.businesslogic.ireport.connection.*;

import it.businesslogic.ireport.*;

import java.util.*;

import java.lang.*;

 

public class PHPJRConnector

{

private HashMap parametres;

public PHPJRConnector(){

this.parametres = new HashMap();

}

public String run(String srcFileName, String dstFileName)

{

try {

dori.jasper.engine.JasperPrint print=null;

dori.jasper.engine.JRExporter exporter=null;

////////////////////////////////////////////////

// CONNEXION A LA BASE DE DONNEES

////////////////////////////////////////////////

 

JDBCConnection maConnection = new JDBCConnection();

maConnection.setJDBCDriver("com.mysql.jdbc.Driver");

maConnection.setUrl("jdbc:mysql://myServer/myDatabase");

//maConnection.setDatabase("deptest");

maConnection.setUsername("myUser");

maConnection.setPassword("myPass");

 

////////////////////////////////////////////////

// EXPORTATION DU RAPPORT EN PDF

////////////////////////////////////////////////

//System.out.print(srcFileName);

//dori.jasper.engine.JasperReport report = dori.jasper.engine.JasperManager.loadReport(srcFileName);

print = dori.jasper.engine.JasperFillManager.fillReport(

srcFileName,

this.getParametres(),

maConnection.getConnection());

 

exporter = new dori.jasper.engine.export.JRPdfExporter();

exporter.setParameter(

JRExporterParameter.OUTPUT_FILE_NAME,dstFileName);

exporter.setParameter(

JRExporterParameter.JASPER_PRINT,print);

exporter.exportReport();

 

return "YES";

} catch (Exception ex)

{

return "ERREUR!";

}

}

 

public void addParametre(String nom,String valeur){

//System.out.print(nom+" "+valeur+" "+this.parametres);

this.parametres.put(nom,valeur);

}

public HashMap getParametres(){

return parametres;

}

 

public void modifieXML(String srcFileName, String dstFileName){

HashMap m = this.getParametres();

 

Report rapport = new Report(srcFileName);

Vector v = new Vector();

 

 

// Modifier des paramè´²es existants

 

v = rapport.getParameters();

Enumeration enum = v.elements();

while (enum.hasMoreElements())

{

it.businesslogic.ireport.JRParameter p = (it.businesslogic.ireport.JRParameter)enum.nextElement();

if (m.containsKey(p.getName().toString()))

p.setDefaultValueExpression(m.get(p.getName()).toString());

}

rapport.setParameters(v);

rapport.saveXMLFile(dstFileName);

}

 

public void compileXML(String srcXML,String dstJASPER){

JasperCompileManager compilateur = new JasperCompileManager();

try{

compilateur.compileReportToFile(srcXML,

dstJASPER);

System.out.print(" OK :-)");

}catch (JRException jrex){

System.out.print("ERREURS de compilation :-(");

}

}

}

</code>

 

 

 

 

By: eric - greatmaster

RE: differences when PDF exporting with PHP

2003-12-01 02:05

i've found the following errors in APACHE :

 

[Mon Dec 01 11:00:10 2003] [error] [client 127.0.0.1] ZoneInfo: c:j2sdklibziZoneInfoMappings (Le chemin d'accè³sp飩fié¥st introuvable)

, referer: http://127.0.0.1/www/

 

anyone knows what it means ?

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...