This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Open PDF document  RSS feed

 
Nicolas Bordenave
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello.

I'm using JasperReports for generate documents, now i want to open the PDFviewer into a JInternalFrame and i don't know.
Right now i'm able to open the Acrobar, and a Browser but not inside my aplication, any ideas?

Thanks,
 
Brandon Broschinsky
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there any reason you want to embed the pdf reader in your application? You could get a handle on the JasperReportsViewer, and embed that in your application to view the report.
 
Nicolas Bordenave
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Brandon you are right. I can open the JasperReport Viewer instance of the acrobat.
I just make this, but i have the same problem, how can i show the viewer inside my aplication? Also when i close the jasper viewer this close my application. This is my code, any idea?


private void print() {
Connection conn;
try {
conn = DriverManager.getConnection("jdbc dbc B_Test", "", "");

JasperReport report = (JasperReport) JRLoader
.loadObject("Reports/lstUsers.jasper");
JasperPrint jasperPrint = JasperManager.fillReport(report, null,
conn);
JasperManager.printReportToPdfFile(jasperPrint,
"C:\\Nico\\Vision\\Reports\\Users.pdf");

JasperViewer.viewReport(jasperPrint);

} catch (SQLException e) {
e.printStackTrace();
} catch (JRException e) {
e.printStackTrace();
}

}
 
Brandon Broschinsky
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can do the following:

Once you have your JasperPrint Object, you could create a JRViewer and pass in your JasperPrint like so:

JRViewer viewer = new JRViewer(jasperPrint);

Since JRViewer extends JPanel you could add this to to your JInternalFrame.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!