aspose file tools
The moose likes Java in General and the fly likes Problem in merging PPT files using java Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Problem in merging PPT files using java" Watch "Problem in merging PPT files using java" New topic
Author

Problem in merging PPT files using java

Parth Pateld
Greenhorn

Joined: Nov 01, 2011
Posts: 29

I want to merge two ppt files using java.
I have used following code. But after execution of a program, the final merged PPT file contains slides from one input file only.But the size of final merged PPT file is summation of both Input ppt file size.

following is the code.
can you me where is the error in it. I have also put output of it. As you can see.


Output:
File Length :: 1 776704
File Length :: 2 342016
total length is 1118720
SequenceInputStream.available() = 776704
soFar = 776704
X = 776704
read = 776704
---- LOOP ----
soFar = 342016
X = 1118720
read = 342016
---- LOOP ----


Thanks in advance
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19216

You can't just add the bytes of two files and expect the resulting file to contain the contents of the two files. Most file formats have a lot of extra information about the file inside it. This information needs to be modified in a format specific way, and the contents of both files also need to be merged in a format specific way. Your approach will work for very, very few formats; plain text is one, but most formats are not that simple.

I suggest you take a look at Apache POI, especially the org.apache.poi.hslf package and its "sub" packages.


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
Saifuddin Merchant
Ranch Hand

Joined: Feb 08, 2009
Posts: 576

and not to mention something like this is really hard to get done even using Apache POI (MS-formats are really complicated, for even POI to handle!)


Cheers - Sam.
Twisters - The new age Java Quiz || My Blog
Parth Pateld
Greenhorn

Joined: Nov 01, 2011
Posts: 29
Rob Spoor wrote:You can't just add the bytes of two files and expect the resulting file to contain the contents of the two files. Most file formats have a lot of extra information about the file inside it. This information needs to be modified in a format specific way, and the contents of both files also need to be merged in a format specific way. Your approach will work for very, very few formats; plain text is one, but most formats are not that simple.

I suggest you take a look at Apache POI, especially the org.apache.poi.hslf package and its "sub" packages.

Thanks for your quick response.
I have also used same package mentioned you org.apache.poi.hslf
In that I have taken Slides from Input PPT files.
but after merging i am getting final PPT file contains total number of slides = summation of (Input PPT files slides) .
Like A.ppt having 10 slides and B.ppt having 16 slides, then i am getting 26 slides ....but all 26 slides are null.
All slides are blank.
So can not now what to do now.
I can not find method in org.apache.poi.hslf to add slides in new PPT file.
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2407
It's probably not just the Slide objects you need to copy, but also their sub-objects like titles, backgrounds, text runs, images, etc. Also be aware that its javadocs state "For now, it only does the text side of things though" - which I understand to mean that you can't even access some of a slide's constituent parts.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19216

Which probably means that you will need a different library. I even expect that you will have to pay for it, as there aren't many free ones. You might get some results from OpenOffice / JODConverter but I haven't used those.

And welcome to the Ranch of course!
Parth Pateld
Greenhorn

Joined: Nov 01, 2011
Posts: 29
Rob Spoor wrote:Which probably means that you will need a different library. I even expect that you will have to pay for it, as there aren't many free ones. You might get some results from OpenOffice / JODConverter but I haven't used those.

And welcome to the Ranch of course!

I have found the link in which they are using C# for merging two or more PPT files.
http://openxmldeveloper.org/blog/b/openxmldeveloper/archive/2011/01/28/110420.aspx Link for merging PPT files using C#.
http://www.codeproject.com/KB/cross-platform/javacsharp.aspxLink for calling C# function from Java File.
Can we use that C# code from Java File, and merge PPT files.
But I dont know how to call C# function from a Java class.
Can you help me on this.
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2407
Parth Pateld wrote:But I dont know how to call C# function from a Java class.

That's what the second article explains, isn't it? After working through it (by which I mean compiling and linking all the involved source codes), do you have a specific question about the process?
Parth Pateld
Greenhorn

Joined: Nov 01, 2011
Posts: 29
Tim Moores wrote:
Parth Pateld wrote:But I dont know how to call C# function from a Java class.

That's what the second article explains, isn't it? After working through it (by which I mean compiling and linking all the involved source codes), do you have a specific question about the process?

Yes I dont know what are the steps to call C# function in Java File.
What is .netmodule file and .dll file used in that second article.
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2407
Did you download the source code and demo project? Did you get it to build?
Parth Pateld
Greenhorn

Joined: Nov 01, 2011
Posts: 29
Yes, I have downloaded that sample project from that second link from "code project" and also run Project in Netbeans which call a C# function from Java file.
To call C# function, they are using .netmodule and .dll file of the C# project.
following is the code which i have found in Java File which is calling C# function

They have put both .netmodule and .dll file in Java Project. and might using " System.loadLibrary(""); " they are loding C# code library.
But I dont know where is that C# file and how can I make changes into it.
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2407
If the source code can't be downloaded by following the "Download source files" link then you should contact the author of that article to get the link fixed.

Besides, isn't all the source code also part of the article?
Parth Pateld
Greenhorn

Joined: Nov 01, 2011
Posts: 29
Tim Moores wrote:If the source code can't be downloaded by following the "Download source files" link then you should contact the author of that article to get the link fixed.

Besides, isn't all the source code also part of the article?

I can download the source code available on code project.
There is a C# project folder, in which they have created a simple C# file and having displayHelloWorld() , function which is called by Java file as you can see in my last post.
Then they have made .netmodule and .dll file of that C# project, and used those file Jave Project to call that C# function in Java file.
But I dont know to make that .netmodule file and .dll file of C# project.
Do I need to use Visual Studio to open that C# project and to make changes into it. and after making changes into that C# file I have to create new .netmodule and .dll file of the same C# project.

Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2407
I'm sure you can edit the files using any editor you like, but to compile and link you'd need to use C#/.Net tools. This is likely not the right web site to get help with that, though
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem in merging PPT files using java
 
Similar Threads
Problem in setBinaryStream when using SequenceInputStream
Apache POI 2007 word documents
SequenceInputStream performance
Merging byte arrays using SequenceInputStream
Merge and split file