• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem in merging PPT files using java  RSS feed

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
 
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Likes 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 607
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!)
 
Parth Pateld
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Saloon Keeper
Posts: 4036
94
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Saloon Keeper
Posts: 4036
94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Saloon Keeper
Posts: 4036
94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you download the source code and demo project? Did you get it to build?
 
Parth Pateld
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Saloon Keeper
Posts: 4036
94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Saloon Keeper
Posts: 4036
94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!