gt: 					int iFormat = Integer.parseInt(imageFormat);
context: /*
   * ===========================================
   * Java Pdf Extraction Decoding Access Library
   * ===========================================
   *
   * Project Info:  http://www.idrsolutions.com
   *
   * List of all example and a link to zip at http://www.idrsolutions.com/java-code-examples-for-pdf-files/
   *
   * (C) Copyright 1997-2013, IDRsolutions and Contributors.
   *
   *   This file is part of JPedal
   *
   This source code is copyright IDRSolutions 2012
  
  
   *
   *
   * ---------------
   * ConvertPagesToHiResImages.java
   * ---------------
   */
  
  package com.sai.java.pdf2image;
  
  import java.awt.Graphics2D;
  import java.awt.image.BufferedImage;
  import java.io.BufferedOutputStream;
  import java.io.File;
  import java.io.FileOutputStream;
  import java.io.IOException;
  import java.util.HashMap;
  import java.util.Iterator;
  import java.util.Map;
  
  import javax.imageio.IIOImage;
  import javax.imageio.ImageIO;
  import javax.imageio.ImageTypeSpecifier;
  import javax.imageio.metadata.IIOMetadata;
  import javax.imageio.plugins.jpeg.JPEGImageWriteParam;
  import javax.imageio.stream.ImageOutputStream;
  
  import org.jpedal.PdfDecoderInt;
  import org.jpedal.PdfDecoderServer;
  import org.jpedal.color.ColorSpaces;
  import org.jpedal.constants.JPedalSettings;
  import org.jpedal.constants.PageInfo;
  import org.jpedal.exception.PdfException;
  import org.jpedal.fonts.FontMappings;
  import org.jpedal.io.ColorSpaceConvertor;
  import org.jpedal.io.JAIHelper;
  import org.jpedal.objects.PdfPageData;
  import org.jpedal.utils.LogWriter;
  import org.w3c.dom.Element;
  
  import com.sun.imageio.plugins.jpeg.JPEGImageWriter;
  
  public class ConvertPagesToHiResImages {
  
  	private static boolean debug = false;
  
  	/** correct separator for OS */
  	final static String separator = System.getProperty("file.separator");
  
  	// only used if between 0 and 1
  	private float JPEGcompression = -1f;
  
  	public static void main(String[] args) throws Exception {
  
  		/*
  		 * Change these variables
  		 */
  		String fileType, pdfFile;
  
  		pdfFile = "C:\\Users\\sai.dandem\\Desktop\\AA.pdf";
  		fileType = "jpg";
  
  		// open the file
  		if (!pdfFile.startsWith(".")
  				&& pdfFile.toLowerCase().endsWith(".pdf")
  				&& (fileType.equals("jpg") || fileType.equals("jpeg") || fileType.equals("png") || fileType.equals("tiff") || fileType
  						.equals("tif"))) {
  			new ConvertPagesToHiResImages(fileType, pdfFile);
  		} else { // open the directory
  
  			File testDir = new File(pdfFile);
  
  			if (testDir.isDirectory()) {
  
  				/**
  				 * get list of files and check directory
  				 */
  
  				String[] files = null;
  				File inputFiles;
  
  				/** make sure name ends with a deliminator for correct path later */
  				if (!pdfFile.endsWith(separator))
  					pdfFile = pdfFile + separator;
  
  				try {
  					inputFiles = new File(pdfFile);
  
  					files = inputFiles.list();
  				} catch (Exception ee) {
  					LogWriter.writeLog("Exception trying to access file " + ee.getMessage());
  				}
  
  				/** now work through all pdf files */
  				for (String file : files) {
  
  					if (file.toLowerCase().endsWith(".pdf"))
  						new ConvertPagesToHiResImages(fileType, pdfFile + file);
  				}
  			} else
  				System.out.println("The file to be processed has to be a pdf and the output filetype can only be jpg,png or tiff");
  		}
  		// System.out.println("Not enough arguments passed in! Usage: \"C:\\examples\\1.pdf\" \"jpg\"");
  
  	}
  
  	/**
  	 * main constructor to convert PDF to img
  	 * 
  	 * @param fileType
  	 * @param pdfFile
  	 * @throws Exception
  	 */
  	public ConvertPagesToHiResImages(String fileType, String pdfFile) throws Exception {
  
  		long startTime = System.currentTimeMillis();
  
  		String outputPath = pdfFile.substring(0, pdfFile.toLowerCase().indexOf(".pdf")) + separator;
  		File outputPathFile = new File(outputPath);
  		if (!outputPathFile.exists() || !outputPathFile.isDirectory()) {
  			if (!outputPathFile.mkdirs()) {
  				if (debug)
  					System.err.println("Can't create directory " + outputPath);
  			}
  		}
  
  		// PdfDecoder object provides the conversion
  		final PdfDecoderInt decoder = new PdfDecoderServer(true);
  
  		// mappings for non-embedded fonts to use
  		FontMappings.setFontReplacements();
  
  		decoder.openPdfFile(pdfFile);
  
  		/**
  		 * this process is very flaxible to we create a Map and pass in values to select what sort of results we want. There is a choice
  		 * between methods used and image size. Larger images use more memory and are slower but look better
  		 */
  		Map mapValues = new HashMap();
  
  		/** USEFUL OPTIONS */
  		// do not scale above this figure
  		mapValues.put(JPedalSettings.EXTRACT_AT_BEST_QUALITY_MAXSCALING, 2);
  
  		// alternatively secify a page size (aspect ratio preserved so will do best fit)
  		// set a page size (JPedal will put best fit to this)
  		mapValues.put(JPedalSettings.EXTRACT_AT_PAGE_SIZE, new String[] { "2000", "1600" });
  
  		// which takes priority (default is false)
  		mapValues.put(JPedalSettings.PAGE_SIZE_OVERRIDES_IMAGE, Boolean.TRUE);
  
  		PdfDecoderServer.modifyJPedalParameters(mapValues);
  
  		if (debug)
  			System.out.println("pdf : " + pdfFile);
  
  		try {
  			/**
  			 * allow output to multiple images with different values on each
  			 * 
  			 * Note we REMOVE shapes as it is a new feature and we do not want to break existing functions
  			 */
  			String separation = System.getProperty("org.jpedal.separation");
  			if (separation != null) {
  
  				Object[] sepValues = new Object[] { 7, "", Boolean.FALSE }; // default of normal
  				if (separation.equals("all")) {
  					sepValues = new Object[] { PdfDecoderServer.RENDERIMAGES, "image_and_shapes", Boolean.FALSE,
  							PdfDecoderServer.RENDERIMAGES + PdfDecoderServer.REMOVE_RENDERSHAPES, "image_without_shapes", Boolean.FALSE,
  							PdfDecoderServer.RENDERTEXT, "text_and_shapes", Boolean.TRUE, 7, "all", Boolean.FALSE,
  							PdfDecoderServer.RENDERTEXT + PdfDecoderServer.REMOVE_RENDERSHAPES, "text_without_shapes", Boolean.TRUE };
  				}
  
  				int sepCount = sepValues.length;
  				for (int seps = 0; seps < sepCount; seps = seps + 3) {
  
  					decoder.setRenderMode((Integer) sepValues[seps]);
  					extractPageAsImage(fileType, outputPath, decoder, "_" + sepValues[seps + 1], (Boolean) sepValues[seps + 2]); // boolean
  																																	// makes
  																																	// last
  																																	// transparent
  																																	// so we
  																																	// can
  																																	// see
  																																	// white
  																																	// text
  				}
  
  			} else
  				// just get the page
  				extractPageAsImage(fileType, outputPath, decoder, "", false);
  
  		} finally {
  
  			decoder.closePdfFile();
  		}
  		System.out.println("time=" + (System.currentTimeMillis() - startTime) / 1000);
  
  	}
  
  	/**
  	 * convenience method to get a page as a BufferedImage quickly - for bulk conversion, use the other methods
  	 */
  	@SuppressWarnings("UnusedDeclaration")
  	public static BufferedImage getHiresPage(int pageNo, int scaling, String pdfFile) {
  
  		BufferedImage imageToSave = null;
  
  		final PdfDecoderInt decoder = new PdfDecoderServer(true);
  
  		try {
  			// mappings for non-embedded fonts to use
  			FontMappings.setFontReplacements();
  
  			decoder.openPdfFile(pdfFile);
  
  			PdfPageData pageData = decoder.getPdfPageData();
  			int width = scaling * pageData.getCropBoxWidth(pageNo);
  			int height = scaling * pageData.getCropBoxHeight(pageNo);
  
  			Map mapValues = new HashMap();
  
  			/** USEFUL OPTIONS */
  			// do not scale above this figure
  			mapValues.put(JPedalSettings.EXTRACT_AT_BEST_QUALITY_MAXSCALING, 2);
  
  			// alternatively secify a page size (aspect ratio preserved so will do best fit)
  			// set a page size (JPedal will put best fit to this)
  			mapValues.put(JPedalSettings.EXTRACT_AT_PAGE_SIZE, new String[] { String.valueOf(width), String.valueOf(height) });
  
  			// which takes priority (default is false)
  			mapValues.put(JPedalSettings.PAGE_SIZE_OVERRIDES_IMAGE, Boolean.TRUE);
  
  			PdfDecoderServer.modifyJPedalParameters(mapValues);
  
  			imageToSave = decoder.getPageAsHiRes(pageNo, null, false);
  
  		} catch (PdfException e) {
  			e.printStackTrace();
  		} finally {
  
  			decoder.closePdfFile();
  		}
  		return imageToSave;
  	}
  
  	/**
  	 * actual conversion of a PDF page into an image
  	 * 
  	 * @param fileType
  	 * @param outputPath
  	 * @param decoder
  	 * @param prefix
  	 * @param isTransparent
  	 * @throws PdfException
  	 * @throws IOException
  	 */
  	private void extractPageAsImage(String fileType, String outputPath, PdfDecoderInt decoder, String prefix, boolean isTransparent)
  			throws PdfException, IOException {
  
  		// page range
  		int start = 1, end = decoder.getPageCount();
  
  		// container if the user is creating a multi-image tiff
  		BufferedImage[] multiPages = new BufferedImage[1 + (end - start)];
  
  		/**
  		 * set of JVM flags which allow user control on process
  		 */
  
  		// ////////////////TIFF OPTIONS/////////////////////////////////////////
  
  		String multiPageFlag = System.getProperty("org.jpedal.multipage_tiff");
  		boolean isSingleOutputFile = multiPageFlag != null && multiPageFlag.toLowerCase().equals("true");
  
  		String tiffFlag = System.getProperty("org.jpedal.compress_tiff");
  		boolean compressTiffs = tiffFlag != null && tiffFlag.toLowerCase().equals("true");
  
  		// ////////////////JPEG OPTIONS/////////////////////////////////////////
  
  		// allow user to specify value
  		String rawJPEGComp = System.getProperty("org.jpedal.compression_jpeg");
  		if (rawJPEGComp != null) {
  			try {
  				JPEGcompression = Float.parseFloat(rawJPEGComp);
  			} catch (Exception e) {
  				e.printStackTrace();
  			}
  			if (JPEGcompression < 0 || JPEGcompression > 1)
  				throw new RuntimeException("Invalid value for JPEG compression - must be between 0 and 1");
  
  		}
  
  		String jpgFlag = System.getProperty("org.jpedal.jpeg_dpi");
  
  		// /////////////////////////////////////////////////////////////////////
  
  		for (int pageNo = start; pageNo < end + 1; pageNo++) {
  
  			if (debug)
  				System.out.println("page : " + pageNo);
  
  			/**
  			 * If you are using decoder.getPageAsHiRes() after passing additional parameters into JPedal using the static method
  			 * PdfDecoder.modifyJPedalParameters(), then getPageAsHiRes() wont necessarily be thread safe. If you want to use
  			 * getPageAsHiRes() and pass in additional parameters, in a thread safe mannor, please use the method getPageAsHiRes(int
  			 * pageIndex, Map params) or getPageAsHiRes(int pageIndex, Map params, boolean isTransparent) and pass the additional parameters
  			 * in directly to the getPageAsHiRes() method without calling PdfDecoder.modifyJPedalParameters() first.
  			 * 
  			 * Please see org/jpedal/examples/images/ConvertPagesToImages.java.html for more details on how to use HiRes image conversion
  			 */
  			BufferedImage imageToSave = decoder.getPageAsHiRes(pageNo, null, isTransparent);
  
  			String imageFormat = System.getProperty("org.jpedal.imageType");
  			if (imageFormat != null) {
  				if (isNumber(imageFormat)) {
  