0

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);
Akash Chavda
  • 1,185
  • 1
  • 11
  • 29
  • 1
    *"there is more text in pdf i cant share original pdf content otherwise i will show you"* No need to share the whole document, but you could create a proper [mre], write a document in Word or something using some Lorem Ipsum text, save the document as PDF and try to display it. However this line `panel.setBounds(470, 0, 600, 700);` tells me you're using `null-layout` which is a bad choice. It may be the root of your problems. – Frakcool Jul 21 '20 at 18:14
  • @Frakcool actually this is not my whole source code.. this is part of code for my appication. I just posted that source code that show pdf content in panel – Akash Chavda Jul 22 '20 at 05:27
  • @Frakcool and yes some of files content showing properly but very rare file content is not showing may be like pdf have interactive form fields. – Akash Chavda Jul 22 '20 at 05:29
  • And I never asked for the whole source code, but for an [mre] (a brand new code that isolated the issue), that will allow us to copy-paste-compile-run the code and see the same issue as you. If you want specific help for your specific problem, help us to help you with the MRE requested, it should fit in about 100-150 lines of code and should take you about 30-60 mins to develop. I'm off to bed now. If you reply I'll see it tomorrow – Frakcool Jul 22 '20 at 05:30
  • @Frakcool I have this same issue http://jira.icesoft.org/browse/PDF-1050 but i dont know how to get that jar file – Akash Chavda Jul 22 '20 at 06:32
  • If you go to the release notes, it was fixed on version [6.2.0](http://jira.icesoft.org/browse/PDF-1056?jql=project%20%3D%20PDF%20AND%20fixVersion%20%3D%206.2%20ORDER%20BY%20updated%20DESC%2C%20priority%20DESC%2C%20created%20ASC). So use that version and that's it. – Frakcool Jul 22 '20 at 15:13
  • @Frakcool but i am not able to download that zip files http://www.icesoft.org/java/downloads/icepdf-downloads.jsf from this page. – Akash Chavda Jul 23 '20 at 03:59
  • Then I can't help you. This is a site for programming questions, not how to download software. You'll have to find a way or try another library – Frakcool Jul 23 '20 at 06:15
  • Or you should pick the most recent one, which should contain the fix as well – Frakcool Jul 23 '20 at 14:22

0 Answers0