BIRT Exchange Forum: ReportEngine-API: PDF rendering fails - BIRT Exchange Forum

Jump to content


 

BIRT Poll: Have you ever done any development work on mobile?

Yes - lotsYes - someNo - but plan toNo time or interestWhat is mobile?
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

ReportEngine-API: PDF rendering fails Changing the render from HTML to PDF has no effect on the result. Rate Topic: -----

#1 User is offline   locutuz Icon

  • Member
  • PipPip
  • Group: Members
  • Posts: 24
  • Joined: 25-October 11


Posted 16 February 2012 - 02:49 AM

Hello everybody,

I have a problem generating a report in PDF format with the ReportEngine-API.
I want to generate a report depending on the user's choice on the GUI. HTML or PDF.
For the HTML stuff, the implementation works fine. Now I wanted to extend my
generator tool that it also can generate PDF.

Like it is described in the example on
http://www.eclipse.o...php#irendertask
I thought it would be enough to only change the specific IRenderOption:

Instead of HTMLRenderOption I use PDFRenderOption and chenged the output file to
e.g. "report1.pdf" in case of PDF. Unfortunately this doesn't work.
Indeed there is a new file in the output location "report1.pdf", but when I want to
open the file, the PDF-reader says that it isn't a PDF file and that it looks like HTML.

Now I suppose that the rendering still is in HTML instead of PDF.

When I let show me the report within the designer (Run -> View Report -> As PDF) the report is shown
as PDF in the PDF-reader.

Where is my fault?
Did I forget something to get my generator tool producing PDF?

The attached file is a zip file of an eclipse example project that demonstrates my generator-tool.
The generator tool is a command-line-tool. It can be run from within eclipse, the launch-configs are also contained in the archive. The database is the BIRT-example database. So it should be easy to get the program run.

Thanks for any help!

Regards,
Sebastian

Attached File(s)


0

#2 User is offline   cbrell Icon

  • Member
  • Group: Members
  • Posts: 523
  • Joined: 17-March 09


Posted 16 February 2012 - 06:17 AM

Hi Sebastian,

this is a very common mistake.
If you want to generate a report in some other format then PDF you have to set the format accordingly using the RenderOption object

PDFRenderOption o = new PDFRenderOption();
o.setOutputFormat(RenderOption.OUTPUT_FORMAT_PDF); //do not forget this line otherwise it's html



or set the corresponding emitter:

PDFRenderOption o = new PDFRenderOption();
o.setEmitterID(RenderOption.OUTPUT_EMITTERID_PDF);



hope this helps
Christian
Interested to join BIRT User Group Mannheim (Germany)?
Have a look at: http://www.xing.com/...-group-mannheim or write me an email
0

#3 User is offline   cbrell Icon

  • Member
  • Group: Members
  • Posts: 523
  • Joined: 17-March 09


Posted 16 February 2012 - 06:23 AM

Another thing that i wanted to bring up (i do not know if it's of relevance for you):

I ve seen that you have multiple report parameters to give the connection details for the database.
You can also inject a existing JDB connection into a report. When injecting a jdbc connection it replaces every database connection in your report.
Interested to join BIRT User Group Mannheim (Germany)?
Have a look at: http://www.xing.com/...-group-mannheim or write me an email
0

#4 User is offline   locutuz Icon

  • Member
  • PipPip
  • Group: Members
  • Posts: 24
  • Joined: 25-October 11


Posted 16 February 2012 - 06:55 AM

View Postcbrell, on 16 February 2012 - 06:23 AM, said:

Another thing that i wanted to bring up (i do not know if it's of relevance for you):

I ve seen that you have multiple report parameters to give the connection details for the database.
You can also inject a existing JDB connection into a report. When injecting a jdbc connection it replaces every database connection in your report.


Thank you for that hint :-)
But so far our "database" is an XML file that is generated by another tool.
So in the "real-life" project, there is a report parameter that contains the location of that XML file.
Only for this example I use a JDBC connection so it can be run as fast as possible :-)

Regards,
Sebastian
0

#5 User is offline   locutuz Icon

  • Member
  • PipPip
  • Group: Members
  • Posts: 24
  • Joined: 25-October 11


Posted 16 February 2012 - 06:56 AM

View Postcbrell, on 16 February 2012 - 06:17 AM, said:

Hi Sebastian,

this is a very common mistake.
If you want to generate a report in some other format then PDF you have to set the format accordingly using the RenderOption object

PDFRenderOption o = new PDFRenderOption();
o.setOutputFormat(RenderOption.OUTPUT_FORMAT_PDF); //do not forget this line otherwise it's html



or set the corresponding emitter:

PDFRenderOption o = new PDFRenderOption();
o.setEmitterID(RenderOption.OUTPUT_EMITTERID_PDF);



hope this helps
Christian



Hello Christian,

thank you for your very fast reply. I didn't expect an answer today (CET 03:28 pm) :-)

Unfortunately your suggestion(s) didn't solve my problem :-(
I tried it in both ways and in both the generation ended-up in an exception.

-------------------------------------------------------------
first
---------
Feb 16, 2012 3:22:42 PM org.eclipse.birt.report.engine.api.impl.EngineTask setupRenderOption
Schwerwiegend: Error.OutputFormatNotSupported
Error creating report engine. The output format pdf is not supported.

second:
-------
Feb 16, 2012 3:24:08 PM org.eclipse.birt.report.engine.api.impl.EngineTask setupRenderOption
Schwerwiegend: Error.InvalidEmitterID
Error creating report engine. EmitterID org.eclipse.birt.report.engine.emitter.pdf for render option is invalid.
----------------------------------------------------------------

For me it looks like a version problem of the BIRT engine. But when I check the plugin-versions in eclipse
they say version: 3.7.3.20110905

Do I have a version problem?

Thanks in advance!

Regards,
Sebastian
0

#6 User is offline   cbrell Icon

  • Member
  • Group: Members
  • Posts: 523
  • Joined: 17-March 09


Posted 16 February 2012 - 09:06 AM

Hi,

it looks like it couldn't find the corresponding PDF emitter. Can you please write which jar files you have in your classpath of your report generator application?

It is OSGI based...correct?
In that case i need to know the plugins that are deployed to that platform.
the BIRT runtime would not work if you miss some of the plugins.
I would have a look at your project if there s the possibility for you to share your code.
Interested to join BIRT User Group Mannheim (Germany)?
Have a look at: http://www.xing.com/...-group-mannheim or write me an email
0

#7 User is offline   locutuz Icon

  • Member
  • PipPip
  • Group: Members
  • Posts: 24
  • Joined: 25-October 11


Posted 16 February 2012 - 09:58 PM

View Postcbrell, on 16 February 2012 - 09:06 AM, said:

Hi,

it looks like it couldn't find the corresponding PDF emitter. Can you please write which jar files you have in your classpath of your report generator application?

It is OSGI based...correct?
In that case i need to know the plugins that are deployed to that platform.
the BIRT runtime would not work if you miss some of the plugins.
I would have a look at your project if there s the possibility for you to share your code.


Hi Christian,

thanks again for your reply.
You were right what you said about the missing jar.
After I put the jar: org.eclipse.birt.report.engine.emitter.pdf to the dependencies list in the plugin manifest and to the corresponding launch config, the report is generated as expected as a correct PDF-file that even can be opened by the PDF-reader without any errors! :-)

For the reason of completeness I attached my example plugin that works correctly so far! :-)

Thanks again for your help!!
I am sure I will return to the forum in the foreseeable future! :-)

Regards,
Sebastian

Attached File(s)


0

#8 User is offline   cbrell Icon

  • Member
  • Group: Members
  • Posts: 523
  • Joined: 17-March 09


Posted 17 February 2012 - 12:15 AM

Good to hear that you were able to solve the problem.
Interested to join BIRT User Group Mannheim (Germany)?
Have a look at: http://www.xing.com/...-group-mannheim or write me an email
0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users