views:

1271

answers:

4

Can I open a ".pdf" document on a blackberry using java?

If yes, then how?

A: 

I'm not sure about Blackberry exactly, but Java 6 SE has a Desktop class which can be used to open a .pdf file with a program associated with that extension, on that platform.

Try something like this:

 if (Desktop.isDesktopSupported()) {
  Desktop desktop = Desktop.getDesktop();
  if (desktop.isSupported(Desktop.Action.OPEN)) {
   File pdf = new File(...);  // path to pdf file
   try {
    desktop.open(pdf);
   }
   catch (IOException e) {
    System.err.println("Could not open " + pdf);
   }
  }
 }
javashlook
RIM Blackberry is a mobile platform. It's using j2me and own api.
Max Gontar
A: 

My blackberry could open PDF's right out of the box. renders them on a small screen really nice too. I dont know why you would need to code something in Java to do so. Just let the shell open it using the built in viewer.

Neil N
A: 

It is not possible to open a PDF file on the BlackBerry from within a Java program. Since OS 4.5 (I think) the BlackBerry has a built-in PDF reader but it only works when you receive a PDF file via email. Not even stored PDF files on the sd card can be opened.

So, "no" it is not possible to open a PDF in Java.

Except of course, when you write a PDF reader first.

kozen
+1  A: 

The BB doesn't have a built-in PDF viewer. You can view PDF attachments in emails, but that works with some server-side magic. I think the best approach is to purchase a 3rd-party viewer and launch that to view the PDF.

Possible viewers include the following. I've not tried any of these yet.

I think you'd end up using net.rim.device.api.system.ApplicationManager, but I've not tried it yet.

Phil