[
https://issues.apache.org/jira/browse/PDFBOX-1209?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Tilman Hausherr closed PDFBOX-1209.
-----------------------------------
Resolution: Duplicate
Done in PDFBOX-2677.
> Add insertSiblingBefore() to PDOutlineItem
> ------------------------------------------
>
> Key: PDFBOX-1209
> URL: https://issues.apache.org/jira/browse/PDFBOX-1209
> Project: PDFBox
> Issue Type: New Feature
> Components: PDModel
> Affects Versions: 1.6.0, 2.0.0
> Reporter: Gilad Denneboom
> Assignee: Tilman Hausherr
> Priority: Minor
> Labels: bookmarks
> Fix For: 2.0.0
>
>
> At the moment it's not possible to insert a first child to a pre-existing
> PDDocumentOutline because all the available methods only allow you to add a
> PDOutlineItem at the end of the list (PDDocumentOutline.appendChild()) or
> after an existing child (PDOutlineItem.insertSiblingAfter()). As a result, if
> you wish to insert a new first child, you have to manually traverse and
> re-create the entire tree, which is ridiculous.
> As a solution, I offer to add a new method to the PDOutlineItem class,
> insertSiblingBefore(). I've written the code necessary based on
> insertSiblingAfter(). It's very straight-forward...
> {code}
> /**
> * Insert a sibling before this node.
> *
> * @param item The item to insert.
> */
> public void insertSiblingBefore( PDOutlineItem item )
> {
> item.setParent( getParent() );
> PDOutlineItem previous = getPreviousSibling();
> setPreviousSibling( item );
> item.setNextSibling( this );
> if( previous != null )
> {
> item.setPreviousSibling( previous );
> previous.setNextSibling( item );
> }
> updateParentOpenCount( 1 );
> }
> {code}
> I hope this can be integrated in the next release...
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]