JAVA SWING ICEPDF pdf not showing whole content

648 Views Asked by At

I am creating one small desktop application using SWING where i have one requirement to show PDF in preview panel. For achieve this requirement i am using ICEPDF library with below versions

<!-- https://mvnrepository.com/artifact/org.icepdf.os/icepdf-core -->
<dependency>
    <groupId>org.icepdf.os</groupId>
    <artifactId>icepdf-core</artifactId>
    <version>6.1.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.icepdf.os/icepdf-core -->
<dependency>
    <groupId>org.icepdf.os</groupId>
    <artifactId>icepdf-viewer</artifactId>
    <version>6.1.2</version>
</dependency>

or

<!-- https://mvnrepository.com/artifact/org.icepdf/icepdf-core -->
<dependency>
    <groupId>org.icepdf</groupId>
    <artifactId>icepdf-core</artifactId>
    <version>4.1.1</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.icepdf/icepdf-core -->
<dependency>
    <groupId>org.icepdf</groupId>
    <artifactId>icepdf-viewer</artifactId>
    <version>4.1.1</version>
</dependency>

but it is not working properly

When i am using org.icepdf - icepdf-core and org.icepdf - icepdf-viewer at that time pdf showing like this enter image description here

there is more text in pdf i cant share original pdf content otherwise i will show you

and when i am using org.icepdf.os - icepdf-core and org.icepdf.os - icepdf-viewer at that time i got below exception

The type org.icepdf.core.views.DocumentViewController cannot be resolved. It is indirectly referenced from required .class files

can you please how to show whole pdf content in my preview panel?

my whole source code is below

                    JPanel panel = new JPanel();
                    panel.setBounds(470, 0, 600, 700);
    
                    // Construct a PropertiesManager from the default properties
                    // file and default message bundle
                    PropertiesManager properties = new PropertiesManager(
                            System.getProperties(),
                            ResourceBundle
                                    .getBundle(PropertiesManager.DEFAULT_MESSAGE_BUNDLE));
    
                    // Build a SwingViewFactory configured with the controller
                    SwingViewBuilder factory = new SwingViewBuilder(controller,
                            properties);
    
                    // Use the factory to build a JPanel that is pre-configured
                    // with a complete, active Viewer UI.
                    viewerComponentPanel = factory.buildViewerPanel();
                    viewerComponentPanel.setPreferredSize(new Dimension(580, 650));
                    viewerComponentPanel.setMaximumSize(new Dimension(580, 650));
                    // add copy keyboard command
                    ComponentKeyBinding.install(controller, viewerComponentPanel);
    
                    controller.setPageViewMode(
                            DocumentViewControllerImpl.ONE_COLUMN_VIEW, false);
    
                    // add interactive mouse link annotation support via callback
                    controller.getDocumentViewController().setAnnotationCallback(
                            new org.icepdf.ri.common.MyAnnotationCallback(
                                    controller.getDocumentViewController()));
    
                    // Create a JFrame to display the panel in
                    panel.add(viewerComponentPanel, BorderLayout.CENTER);
    
                    contentPane.add(panel);

                    controller.openDocument(file);
0

There are 0 best solutions below