I am trying to display a remote pdf in JFrame using ICEpdf. I copied the code from their website to get started, which is:
import org.icepdf.ri.common.SwingViewBuilder;
import org.icepdf.ri.common.MyAnnotationCallback;
import javax.swing.*;
class ViewerComponentExample {
public static void main(String[] args) {
// Get a file from the command line to open
String filePath = "http://www.orimi.com/pdf-test.pdf";
// build a component controller
SwingController controller = new SwingController();
SwingViewBuilder factory = new SwingViewBuilder(controller);
JPanel viewerComponentPanel = factory.buildViewerPanel();
JFrame applicationFrame = new JFrame();
applicationFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
applicationFrame.getContentPane().add(viewerComponentPanel);
// Now that the GUI is all in place, we can try openning a PDF
controller.openDocument(filePath);
// show the component
applicationFrame.pack();
applicationFrame.setVisible(true);
}
}
But I am getting the following error:
ICEpdf could not open the specified file at http://www.icepdf.org/resources/DevelopersGuide.pdf.
The file may be corrupted or not a supported file type.
I am using icepdf-core.jar and icepdf-viewer.jar. Do I need some other jar file to open a remote pdf? I am also unable to ask anything on their forum. I can't see any link to ask my own question there.
If someone has used this thing, please tell me how to resolve this error.
EDIT
I am able to open the remote file using the command java org.icepdf.ri.viewer.Main -loadurl http://www.orimi.com/pdf-test.pdf as stated in their docs, but it fails when I try to open it through the program.
Thank you!
Okk. Getting no help. So I decided to do it by myself. You will not get it anywhere. Even in their documentation. So this is what is need to be done to open a remote pdf file using icepdf.
I realised that there are two overloading methods inside the SwingController class, one which takes a string as an arguement(for opening local pdf files) and another one for opening remote pdfs, which accepts a URL object.