1

Here is my code to open the myFile.pdf file to the page 4 :

public static void main(String[] args) {
    final String filePath = "myFile.pdf";

    // build a component controller
    SwingController controller = new SwingController();

    PropertiesManager properties = new PropertiesManager(System.getProperties(),
        ResourceBundle.getBundle(PropertiesManager.DEFAULT_MESSAGE_BUNDLE));

    properties.setBoolean(PropertiesManager.PROPERTY_SHOW_UTILITY_PRINT, false); 

    SwingViewBuilder factory = new SwingViewBuilder(controller, properties);

    JPanel viewerComponentPanel = factory.buildViewerPanel();

    // add interactive mouse link annotation support via callback
    controller.getDocumentViewController().setAnnotationCallback(
        new MyAnnotationCallback(controller.getDocumentViewController()));

    //controller.getDocumentViewController().setDestinationTarget(controller.getDocument().getCatalog().getDestinations().);

    JFrame applicationFrame = new JFrame();
    applicationFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    applicationFrame.setTitle("Test ICEPdf");
    applicationFrame.getContentPane().add(viewerComponentPanel);

    // Now that the GUI is all in place, we can try openning a PDF
    controller.openDocument(filePath);
    controller.showPage(3);
    // show the component
    applicationFrame.pack();
    applicationFrame.setVisible(true); }

But, I want to navigate into the document without using showPage(), like navigate with the TOC's anchor for example. Because I don't want to change the code if I add content to my PDF file, as the number of pages will change.

Is there a solution ?

Azrix
  • 99
  • 1
  • 10

0 Answers0