Print Page | Close Window

Remove ouline, move children

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=2244
Printed Date: 14 Aug 25 at 6:00AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Remove ouline, move children
Posted By: CThomp2009
Subject: Remove ouline, move children
Date 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?





Replies:
Posted By: CThomp2009
Date 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!



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk