cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X

Merging Documents in Windchill

MichaelWright
1-Newbie

Merging Documents in Windchill

I have been tasked with adopting one of our processes into Windchill and am hoping that someone might be able to help steer me in a right direction on how to accomplish this. Currently we have a presentation process in which Users create a single page PowerPoint presentation that is then used to combine with other presentations. We could have upwards of 50 single page presentations that are then combined into 1 single 50 page presentation. I know this sounds like a somewhat silly task, but it's how our process works here.

My question is, is there a way to use some sort of coding that we could implement that would be able to merge these documents in a specified order based on attributes of the document? This doesn't necessarily have to be PowerPoint, it is just what they are used to using, we may be able to use a different document type if that would be able to accomplish something similar to this. Basically as long as they can project the document on the screen in a combined fashion, I think we would accomplish our goal.

Any help or advise would be great. If it is simply not possible, we will have to find a work around, but I feel this would make life a little easier on our users and help with the adoption of this process. So any ideas that any of you might have would be great.

Thanks for your help.

3 REPLIES 3

My first shot (if possible) is to look whether Arbortext can be used for this (may be there is a bigger scope).

Otherwise we can use document structure.

If you have some naming convention that is followed for each individual page of presentation.

Parent (created at the end)

|->Child 1 (page 1)

|->Child 2 (page 2) etc...

Then we can go thru each child n get to the attachment and write a macro or something to get the content or insert these pages in to the Parent presentation.

This needs a customisation.

I cant think of any ootb way which will do this.

I'm running a migration so I had an hour or so to kill. In my example, you may sort inside the "allPossibleChildren" method. I just don't know what your criteria is so I couldn't help there. Also, I didn't test with complex slides.

package temp;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.apache.poi.hslf.model.Shape;
import org.apache.poi.hslf.model.Slide;
import org.apache.poi.hslf.model.TextBox;
import org.apache.poi.hslf.usermodel.SlideShow;
public class SlideshowTester {
public static void main(String[] args) {
try {
SlideShow parent = findOrCreateParent();
if(parent != null) {
List<SlideShow> possibleChildren = allPossibleChildren();
Iterator<SlideShow> pci = possibleChildren.iterator();
while(pci.hasNext()) {
SlideShow child = pci.next();
Slide childSlides[] = child.getSlides();
if(childSlides != null) {
for(int i = 0; i < childSlides.length; i++) {
Slide slide = parent.createSlide();
clone(childSlides[i],slide);
}
}
}
save(parent,getParentFile());
} else {
System.out.println("Unable to create parent slideshow");
}
} catch (Exception e) {
e.printStackTrace();
}
}
private static void clone(Slide from, Slide to) {
Shape shapes[] = from.getShapes();
if(shapes != null) {
int len = shapes.length;
for(int i = 0; i < len; i++) {
to.addShape(shapes[i]);
}
}
}
private static void save(SlideShow ss, File file) throws IOException {
OutputStream os = null;
try {
os = new FileOutputStream(file);
ss.write(os);
os.close();
} catch(IOException e) {
if(os != null) {
try {
os.close();
} catch (Exception e2) {
}
}
throw e;
}
}
private static SlideShow toSlideShow(File file) {
SlideShow slideShow = null;
InputStream is = null;
try {
is = new FileInputStream(file);
slideShow = toSlideShow(is);
is.close();
} catch(IOException e) {
e.printStackTrace();
if(is != null) {
try {
is.close();
} catch (IOException e1) {
}
}
}
return slideShow;
}
private static SlideShow toSlideShow(InputStream is) throws IOException {
SlideShow slideshow = new SlideShow(is);
return slideshow;
}
private static SlideShow findOrCreateParent() {
SlideShow parent = findParent();
if(parent == null) {
parent = createParent(true);
}
return parent;
}
private static SlideShow createParent(boolean addFirstPage) {
SlideShow ss = null;
try {
ss = new SlideShow();
if(addFirstPage) {
Slide slide = ss.createSlide();
TextBox title = slide.addTitle();
title.setText("very first page title....");
}
save(ss, getParentFile());
} catch(Exception e) {
}
return ss;
}
private static SlideShow findParent() {
File file = getParentFile();
if(file.exists()) {
return toSlideShow(file);
} else {
return null;
}
}
private static File getParentFile() {
File file = new File("C:\\temp\\poi\\slideshow\\parent\\parent.ppt");
return file;
}
private static List<SlideShow> allPossibleChildren() {
File folder = new File("C:\\temp\\poi\\slideshow\\children\\");
File files[] = folder.listFiles();
if(files != null && files.length > 0) {
SlideShow next;
List<SlideShow> list = new ArrayList<SlideShow>();
for(int i = 0; i < files.length; i++) {
next = toSlideShow(files[i]);
if(next != null) {
list.add(next);
} else {
//something went wrong
}
}
//sort?
return list;
} else {
return new ArrayList<SlideShow>();
}
}
}
Top Tags