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.
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.
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
posted
1
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.
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
posted
0
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.
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
posted
0
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
posted
0
Did you download the source code and demo project? Did you get it to build?
Parth Pateld
Greenhorn
Joined: Nov 01, 2011
Posts: 29
posted
0
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
posted
0
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
posted
0
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
posted
0
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