Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Jitendra Nayak
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9280
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic