• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Paul Clapham
  • Devaka Cooray
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Liutauras Vilda
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Piet Souris
Bartenders:
  • salvin francis
  • Carey Brown
  • Frits Walraven

Open PDF document

 
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,
 
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.
 
He loves you so much! And I'm baking the cake! I'm going to put this tiny ad in the cake:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
    Bookmark Topic Watch Topic
  • New Topic