aspose file tools*
The moose likes Other JSE/JEE APIs and the fly likes Am merging images using JAI pls tell it has merging first page of image Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Am merging images using JAI pls tell it has merging first page of image" Watch "Am merging images using JAI pls tell it has merging first page of image" New topic
Author

Am merging images using JAI pls tell it has merging first page of image

Jitendra Nayak
Greenhorn

Joined: Mar 13, 2006
Posts: 9
Hi

This is my updated code:using JAI api

problem is when i merger the documents it was merged.

the first page of documents only merged with another documents.
pls help how should rectify this?




code:
======

public void MergeDocs(String[] path,String finalPath)throws Exception
{

RenderedImage image[] = new PlanarImage[path.length];// give homw many files u are going to merge
System.out.println("The length is ="+path.length);
try
{
for(int i=0;i < image.length; i++)
{
// image[0] = readAsPlanarImage("d://00013131-Quotation.tif");
// image[1] = readAsPlanarImage("d://00013131-App_Form-Pg1.tif");

System.out.println("The path is ="+path[i]);
image[i] = readAsPlanarImage(path[i]);
}
saveAsMultipageTIFF(image,finalPath);
}
catch(Exception e)
{
e.printStackTrace();
throw e;
}

}



public static PlanarImage readAsPlanarImage(String filename)
{
return JAI.create("fileload", filename);
}



public static void saveAsMultipageTIFF(RenderedImage[] image, String file ) throws Exception,java.io.IOException
{
String filename = file;
if(!filename.endsWith(".tiff"))filename = new String(file+".tiff");
OutputStream out = new FileOutputStream(filename);
TIFFEncodeParam param = new TIFFEncodeParam();
ImageEncoder encoder = ImageCodec.createImageEncoder("TIFF", out, param);

Vector vector = new Vector();

for(int i=1;i<image.length;i++)
{
vector.add(image[i]);
}
param.setExtraImages(vector.iterator());
encoder.encode(image[0]);
System.out.println("done");
out.close();
}
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8873
    
    8

Please do not post the same question in more than one forum. We all read multiple forums so you are not increasing your audience. Crossposting can also cause confusion and duplication of effort as the community tries to help everyone out.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Am merging images using JAI pls tell it has merging first page of image