-1

I am making a PDF reader using java and I want to open the PDF file in my own application's JFrame so that I can make my own features. Is there a way to do that? I am using "iText","pdfBox", and "ICEpdf" to manipulate the PDF document.

Mike Laren
  • 8,028
  • 17
  • 51
  • 70
natcomp256
  • 706
  • 7
  • 13
  • For PDFBox, get the source code and look at PDFReader.java and PDFPagePanel.java. But I'd say your question is rather broad and is likely to be flagged. – Tilman Hausherr Apr 07 '15 at 09:24
  • You can use method `convertToImage` of class `PDPage`, and then show the image on JFrame. – cshu Apr 09 '15 at 03:49

1 Answers1

2
  public static void pdfViewerICE() {
        String filePath = "PDF_URL";
        // build a controller
        controller = new SwingController();

        // Build a SwingViewFactory configured with the controller
        SwingViewBuilder factory = new SwingViewBuilder(controller);
           PropertiesManager properties = new PropertiesManager(
                System.getProperties(),
                 ResourceBundle.getBundle(PropertiesManager.DEFAULT_MESSAGE_BUNDLE));

   properties.set(PropertiesManager.PROPERTY_DEFAULT_ZOOM_LEVEL, "1.75");

        // Use the factory to build a JPanel that is pre-configured
        //with a complete, active Viewer UI.
       JPanel viewerComponentPanel = factory.buildViewerPanel();

        controller.openDocument(filePath);
      }

The above code opens PDF using ICEPDF via your java program. Note: Include ICEPDF jar (icepdf-viewer.jar,icepdf-core.jar ) in your classpath http://www.icesoft.org/java/downloads/icepdf-downloads.jsf

Nesh
  • 134
  • 9
  • Hey, can you tell me how can I open remote pdfs using this. When I put the URL to the file, I get the message that icepdf couldn't open the file because it has been corrupted of have incorrect file format even though the pdf was fine. – Vipul Tyagi Apr 25 '20 at 05:29
  • which version that you're using it there @Nesh ? – gumuruh Sep 29 '21 at 15:39