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

Exporting to PDF Reports with its subreport


simonet

Recommended Posts

Hello

Just a question:

 

when I get the object JusperPrint in Java and export it into pdf file, how can I go up again the subreport name, ? because If I get the japser files locally, no problem, but as I have them on a remote server obviousely the FillManager cant find the subreport ones !

 

I mean what method of which class shall I use the get the subreport jasper name ?

 

and if the output format is HTML, how can I get the inputStream of the folder and the other file so that I can store them to a remote server ?

 

 

THANKS YOU

Sincerely

7ab10 simonet

Post edited by: simonet, at: 2007/11/20 10:56

Link to comment
Share on other sites

  • Replies 9
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

You can compile the subreports and then pass them on as paramters.

 

and if the output format is HTML, how can I get the inputStream of the folder and the other file so that I can store them to a remote server ?

 

What do you mean? You want to send the html to a remote server. I dont know how you want to communicate with the report server ftp, samba etc.

Link to comment
Share on other sites

Well I have eXist as Database, an xml database which allow to store also other kind of file format... anyway....

 

I do not know a priori which and how many jasper files are there inside that database, I only know the name of a report.

So once known the report name, or better the report jasper name,

I donwload it using HttpClient and getMethod and I get an InputStream of it and then pass it to the Filler returing a JasperPrint.

now how can I go up to the subreport name ?

arent the subreport names there into the jasper ?!?!

 

As regarding the Html, during the converting, how can I get the Stream of the html file and the directory and its files so that I can store them into the database. Otherwise I should save them into files and then wait and send ....nooo I dont like this way.

 

Thank you very much

 

simonet

Link to comment
Share on other sites

To tell you the truth. I didnt understand a thing you said in the first part. Maybe you could improve your English a bit. It makes it easier to understand you.

 

About this part:

As regarding the Html, during the converting, how can I get the Stream of the html file and the directory and its files so that I can store them into the database.

 

Maybe you misunderstand how the htmlexporter works. It doesnt save to a directory or save a group of files. You can get the html stream from the htmlexporter. It has an string buffer parameter

 

Code:

JRHtmlExporter exp = new JRHtmlExporter ( );

exp.setParameter ( JRExporterParameter.JASPER_PRINT, jasperPrint );
exp.setParameter ( JRExporterParameter.OUTPUT_STRING_BUFFER, stringbuffer );

 

You can then stream the stringbuffer contents to a remote server

Link to comment
Share on other sites

It's not my english, because I write too fast.

Well I tell it again:

 

I have thousands of jasper files stored in a XML Database. Among those jasper there are both reports and subReports. I do not know which are the reports or the subreports.

I was said to write a software that given a report name, it downloads it and exports it into a pdf or html file and store it again to the database.

 

Well I only know the name of the report, so once downloaded it (with my software using an HttpClient and the getMethod) and got its inputStream, how can I get its subReport names so that I can download them, get thier inputStream and merge all togheter.

 

Hope this is clear.

Thanks again

Link to comment
Share on other sites

Your story is clear now.

 

You can compile the main report, and I beleive you can retreive a list of parameters from the compiled main report. You can get the name and class of the parameter. If you find a JasperReport class then you know you have found a subreport. You can then download the subreport with that name. This only happens if the previous user used subreports as parameters.

 

It'a also possible to retreive a list of sub reports from the compile main report. But I'm not really sure about that one. You might have to analyse the jrxml file manually to get all the sub report names.

 

After you download all the subreports you can read the ireport manual how to use subreports in the main report or search this forum how to best do that. It depends on how the previous user solved that problem.

Link to comment
Share on other sites

I try to compile it but an Exception is caught:

org.apache.xerces.impl.io.MalformedByteSequenceException: Invalid byte 1 of 1-byte UTF-8 sequence.

 

the method which I download the report with is getRequestBody that return an array of byte.

I create the InputStream of the report by calling the

new ByteArrayInputStream(arrayOfBytes))

 

so I have an InputStream of the Report.

I pass it to the JasperManager.compileReport which return a JasperReport as you said, but I cant keep on going ahead because that Excepttion is caught.........

 

Thank you

Link to comment
Share on other sites

Are you sure the xml you download is valid? My guess is that the xml isnt downloaded correctly or that it was saved corrupt or is being read corrupt. Your code seams correct so I dont think it's a code problem but more a xml problem or download problem.

 

About the download process. If you do get corrupt xml files then that is something you will have to find out for yourself since that has nothing to do with Jasperreports. Then you will have to consult the manual of the application that downloads the xml files.

Link to comment
Share on other sites

The input Stream belong to jasper file, not to xml file.

 

Excluding the new piece of code the software works, that is when a report is a single one.

 

the new piece of code:

if the report contains other subreports, before filling it I compile it with the CompilerManager and I get that exception.

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