voyent
Expand bookmarks  XML
Forum Index -> ICEpdf General Go to Page: 1, 2, 3 Next 
Author Message
zzalm

Joined: 08/Feb/2018 07:37:33
Messages: 20
Offline


Hello,

I am new to ICEpdf, and I was wondering if it is possible to expand a root bookmark programmatically?

I have already tried to loop the bookmarks and select one to open, which indeed opens the page. But the bookmark navigations stays the same, no changes there.

Many thanks for the help!

patrick.corless

Joined: 26/Oct/2004 00:00:00
Messages: 1982
Offline


There is a reference to the outline tree in the SwingController:outlinesTree. Unfortunately the outlinesTree:JTree object is private.

If you want to alter the SwingController source you can try the attached patch.
 Filename SwingController_commonNewDocumentHandling()_expand_outlines.patch [Disk] Download
 Description
 Filesize 842 bytes
 Downloaded:  452 time(s)

[Email]
zzalm

Joined: 08/Feb/2018 07:37:33
Messages: 20
Offline


Thanks for the quick response! I will give it a try, but I have never patched a class (.jar) before, is there maybe a guide for it?
patrick.corless

Joined: 26/Oct/2004 00:00:00
Messages: 1982
Offline


The process isn't too hard but it does assume some familiarity with, SVN and Gradle or maven. Here are the instructions for building with Mavaen.

1.) First step is to check out the source code from our SVN repository. The url for our latest release is http://anonsvn.icesoft.org/repo/icepdf/tags/icepdf-6.3.0/icepdf/ . If your on windows https://tortoisesvn.net/downloads.html is an excellent SVN client. For linux and macOS the command line is pretty easy to use but you'll need to research that.

2.) Once the code is checked out you'll have it somewhere on your computer. You can apply the patch to the source file :
.\svn\ossrepo\icepdf\tags\icepdf-6.3.0\icepdf\viewer\viewer-awt\src\main\java\org\icepdf\ri\common\SwingController.java

3.) Using Apache Maven you can rebuild the icepdf-viewer.jar Make sure you have a console window open at .\svn\ossrepo\icepdf\tags\icepdf-6.3.0\icepdf\ . And then run the command "mvn clean package -pl :icepdf-viewer -am" The new icepdf-viewer-x.x.x.jar will created in .\svn\ossrepo\icepdf\tags\icepdf-6.3.0\icepdf\viewer\viewer-awt\target . If your are familiar with maven you can also execute "mvn clean install -pl :icepdf-viewer -am" which will put the new jar in your local maven repo.

4.) You'll have page jar now that can be added to your project via direct jar link or via a maven dependency. There is no need to update the icepdf-core.jar as it wasn't affected by the patch.
[Email]
patrick.corless

Joined: 26/Oct/2004 00:00:00
Messages: 1982
Offline


Our wiki has some more information on Gradle as well, http://www.icesoft.org/wiki/display/PDF/Building+From+Source .
[Email]
zzalm

Joined: 08/Feb/2018 07:37:33
Messages: 20
Offline


Almost there! The creation of the new jar was succeed, the guide was very helpfull. One thing to do, because I was working with 6.2.2 version I have to change this

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


But that is for tomorrow :) Feel free to give a suggestion, for now thanks a lot!
patrick.corless

Joined: 26/Oct/2004 00:00:00
Messages: 1982
Offline


For version < 6.3 we used Apache Ant for the build. As you may have see, the command at the root directory is >ant build.jars and it will build both the core and viewer jars. Keep me posted if you run into any other problems.
[Email]
zzalm

Joined: 08/Feb/2018 07:37:33
Messages: 20
Offline


The modification (bookmarks) is working like a charm!! One step to go, and correct me if I am wrong, but is the PropertiesManager class replaced by Preferences class? If so, is there example how to use this Preferences class? I am grateful to you for your help.
patrick.corless

Joined: 26/Oct/2004 00:00:00
Messages: 1982
Offline


Good to hear.

Actually the PropertiesManager wraps the Preferneces api so that it would have less of an impact on our existing users. So you can uses propertiesManger instance as is or get at the preferences object if you want direct access to the api.
[Email]
zzalm

Joined: 08/Feb/2018 07:37:33
Messages: 20
Offline


Strange it gives a error by me (see attachment)
[Thumb - error message.png]
 Filename error message.png [Disk] Download
 Description
 Filesize 12 Kbytes
 Downloaded:  447 time(s)

zzalm

Joined: 08/Feb/2018 07:37:33
Messages: 20
Offline


It says the following: PropertiesManager() has private access in PropertiesManager
patrick.corless

Joined: 26/Oct/2004 00:00:00
Messages: 1982
Offline


I'll updated the wiki but in the new 6.3 the call looks like

Code:
 PropertiesManager properties = PropertiesManager.getInstance();
 // set any properties as before.            
 properties.checkAndStoreFloatProperty(PropertiesManager.PROPERTY_DEFAULT_ZOOM_LEVEL, 1.25f);
 
[Email]
zzalm

Joined: 08/Feb/2018 07:37:33
Messages: 20
Offline


It is working!! Thanks for all the effort!
zzalm

Joined: 08/Feb/2018 07:37:33
Messages: 20
Offline


Although the code compiled, it has no changes in the actually view.

Must I change something in the final steps?

SwingViewBuilder factory = new SwingViewBuilder(controller, properties)
JPanel viewerComponentPanel = factory.buildViewerPanel()

For now I call it a day!
patrick.corless

Joined: 26/Oct/2004 00:00:00
Messages: 1982
Offline


Double check your class-path make sure the newly compiled icepdf-viewer-x.x.x.jar is on it.
[Email]
 
Forum Index -> ICEpdf General Go to Page: 1, 2, 3 Next 
Go to:   
Powered by JForum 2.1.7ice © JForum Team