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!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > I need help - I can help
  New Posts New Posts RSS Feed - Remove ouline, move children
  FAQ FAQ  Forum Search   Register Register  Login Login

Remove ouline, move children

 Post Reply Post Reply
Author
Message
CThomp2009 View Drop Down
Beginner
Beginner
Avatar

Joined: 25 Jan 12
Status: Offline
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote CThomp2009 Quote  Post ReplyReply Direct Link To This Post Topic: Remove ouline, move children
    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
Back to Top
CThomp2009 View Drop Down
Beginner
Beginner
Avatar

Joined: 25 Jan 12
Status: Offline
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote CThomp2009 Quote  Post ReplyReply Direct Link To This Post Posted: 25 Apr 12 at 9:43PM
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
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store