Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

AS400 ImageIO write hangs  RSS feed

 
Don Blodgett
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need splitting a PDF file into JPG files (1 JPG for each page). I am using jPedal to do this on an AS400 with Java 1.5 in headless mode (java.awt.headless=true). The code works perfectly on a PC, but it is not working on the AS400. This is the code segment that writes the file, once it gets to the ImageIO.write line, the process hangs.

<blockquote>code:
<pre name="code" class="core">
private static void saveImage(Image image, String fileName) {
File fileToSave = new File(fileName);
try {
ImageIO.write((RenderedImage) image, "jpg", fileToSave);
} catch (Exception err) {
log.error(err.toString());
}
}
</pre>
</blockquote>

Any help would be greatly appricated.
 
Carey Evans
Ranch Hand
Posts: 225
Debian Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The code below works fine for me on i5/OS V5R4. Can you post a self-contained example that doesn�t?
<blockquote>code:
<pre name="code" class="core">public class PdfTest {
public static void main(String[] args) throws Exception {
PdfDecoder pdf = new PdfDecoder(true);
pdf.openPdfFile(args[0]);
BufferedImage img = pdf.getPageAsImage(1);
ImageIO.write(img, "jpg", new File("temp.jpg"));
}
}
</pre>
</blockquote>
 
Don Blodgett
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, for the response.

Looking at your code made me realize what the problem was. I was using a RenderedImage, which is not correct because the image should never be rendered in the first place. I changed it to a BufferedImage and all is well.

Thanks again.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!