Jump to content
We've recently updated our Privacy Statement, available here ×

How to create a Pdf file from java class


berdohan

Recommended Posts

Hi all;

I am interesting  to create a PDF file from java class using .jasper file.Also my datasource is a XML file datasource. I particularly managed to do it. My  jasper file works exactly when I execute jrxml file in IReport3..0.0.  It creates and views my report that filled up with correct data. If I try to get  my report  calling  from java.class , report looks like empty columns and number of data amount *2. Here is my codes and other files are been athachment  to msg.

Does anyone tell me how I get my report with correct data and use the variable xmldatasource file?

Best regards.

berdohan

Code:

 

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

  • 4 years later...
  • 3 years later...

try {

JRXmlDataSource jrxmlds = new JRXmlDataSource(xmlFileName,recordPath);

JasperPrint print = JasperFillManager.fillReport(reportFileName,hm,jrxmlds);

JRExporter exporter= new JRPdfExporter();

exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME,outFileName);

exporter.setParameter(JRExporterParameter.JASPER_PRINT,print); exporter.exportReport();

Runtime r = Runtime.getRuntime();

try {

String app = {"C:\Program Files\Adobe\Acrobat 7.0\Reader\AcroRd32.exe",outFileName};

Process process = r.exec(app);

System.out.println("app= "+app);

}catch (Exception ee){} }

catch (JRException ex1)

{ ex1.printStackTrace(); System.exit(1); }

catch (Exception ex2)

{ ex2.printStackTrace(); System.exit(1); }

}

Link to comment
Share on other sites

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...