问题
Can I open a ".pdf" document on a blackberry using java?
If yes, then how?
回答1:
theres nothin native in blackberry to load pdf files, but you can achieve that loading google viewer inside your Browser field, that will do the trick! =D!
public ScrLoad()
{
String url = "http://docs.google.com/gview?embedded=true&url=http://prueba.agenciareforma.com/appiphone/android/elnorte.pdf";
add(new BrowserField(url));
}
Google Docs Viewer http://docs.google.com/gview
回答2:
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.
- http://www.cerience.com/products/reader/
- http://www.slgmobile.com/beamreader.html
- http://www.dynoplex.com/
I think you'd end up using net.rim.device.api.system.ApplicationManager, but I've not tried it yet.
回答3:
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.
回答4:
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);
}
}
}
来源:https://stackoverflow.com/questions/726350/can-i-open-a-pdf-document-on-a-blackberry-using-java