Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!
![]() |
Remove ouline, move children |
Post Reply ![]() |
Author | |
CThomp2009 ![]() Beginner ![]() ![]() Joined: 25 Jan 12 Status: Offline Points: 5 |
![]() ![]() ![]() ![]() ![]() Posted: 25 Apr 12 at 5:46PM |
I have an outline situation that's driving me crazy. We generate reports where the end results are pdf files with outlines already in them. Once all the reports are generated, we compile/merge groups of them together into another file (with the outlines combined). This, however, creates duplicate entries in the outlines that I need to remove, and move the child outlines "up"...
Example, the outline structure of a merged file would look like: Cover Table of Contents Bob Dept A Section 1 Section 2 Joe Dept C Section 1 Section 2 Joe Dept D Section 1 Section 2 So the goal here is to remove the second "top-level" instance of "Joe" (because it's duplicated) and move his children up under the children of Joe's first occurrence. The result would be: Cover Table of Contents Bob Dept A Section 1 Section 2 Joe Dept C Section 1 Section 2 Dept D Section 1 Section 2 I've been coding through several different methods, but can't seem to figure out how to do it. Note, there may be multiple instances of several people in a file, and there may be numerous occurrences of a single person within a file. All the dupes would need to be removed with their children moved up under the children of the first occurrence. Additionally, these duplicates will only occur at the top-most (root) level, not below. Any and all help/suggestions would be greatly appreciated! (Day 2 for me trying to make this work correctly!) I'm coding in VB, but can figure out other languages if posted in them. --- UPDATE --- I thought I could just reassign the Parent ID of the second-level child outline to the first instance of the top-level outline, but it doesn't appear that an outline's ParentOutlineID is changeable once set (?) Additionally, when creating an outline, root items get a ParentID of 0, so I thought I could just look for this to detect top-level outlines, but I actually get an ID from something - and it appears to be a different ID for each top-level/root outline. What does this "object" (Parent) ID come from? Edited by CThomp2009 - 25 Apr 12 at 7:20PM |
|
![]() |
|
CThomp2009 ![]() Beginner ![]() ![]() Joined: 25 Jan 12 Status: Offline Points: 5 |
![]() ![]() ![]() ![]() ![]() |
Actually just figured this out myself - although is pretty structured for my own situation...
Loop starts with the FirstOutline's ID, and also captures its Title and FirstChildID in variables. Then checks the Title of the NextOutline (which will be the next outline at the same root level). If they match, it MovesAfter the "NextOutline"'s FirstChildID to the (current) Outline's FirstChildID. The ChildID variable is updated to the one moved (so it's the last in the current hierarchy). The "NextOutline" (the duplicate root outline) is removed. Keeps going like this until NextOutlineID = 0 (no next outline). If the Titles between the current Outline and next Outline don't match, up updates the ID, Title and FirstChildID variables to the "Next" ones (which then become the "current" ones in the next loop). Is very short and sweet code, in the end, and easier to figure out from the code than my explanation. Note, this process is only set up to find dupes that occur right after each other (such is my case), but not dupes that occur further down - anywhere else in the file. I could spend some time doing that, but am good for now with this solution. Thanks to anyone who took a look at this! Edited by CThomp2009 - 25 Apr 12 at 9:45PM |
|
![]() |
Post Reply ![]() |
|
Tweet
|
Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |
Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. About — Contact — Blog — Support — Online Store