asked on November 5, 2019

I'm attempting to import/export a multi page tiff image with JRA however I'm do not know how to iterate through each page. I was able to import/export a electronic document. Based on the documentation that comes with the help files there is a sample that only imports a single page document instead of multi page.

Single Page Import:

if(extension.equalsIgnoreCase("tif")){
            System.out.println("Image Document");
            // Create a page in the document
            Page page = Page.create(result, 1);
            // Import an image into the just created page
            page.write(new File(resource), PagePart.IMAGE);
        }

I added the conditional statement to check to see if it is a tif file. I will be adding more image file types to the condition however I wanted to have this one completed. 

Export Sample:

//Get document pages        
        PageReader pReader = result.getAllPages();
        Page page = null;
        InputStream fileStream = null;
        PageSet pSet = null;
        while (pReader.hasNext()) {
            
            page = pReader.next();
            if (page.hasImage()) {
                fileStream = page.read(PagePart.IMAGE);
                fileStream.close();
            }
        }
        FileOutputStream outPutFile = null;
        
        String ExLocation = "C:\\"+result.getName()+".tiff";
          
        outPutFile = new FileOutputStream(ExLocation);
        
        fileStream.transferTo(outPutFile);
       

I'm fairly new with working with Java so any assistance is appreciated. 

0 0