@Override
	public void write(File file, List<ComicImage> images) throws IOException {
		PDDocument document = new PDDocument();

		for (ComicImage image : images) {
			//Make each page exactly the same size as the image
			PDPage page = new PDPage(new PDRectangle(image.getWidth(), image.getHeight()));
			document.addPage(page);
			FileInputStream fis = null;
			RandomAccessFile raf = null;
			
	        PDXObjectImage ximage = null;
	        if (image.getName().toLowerCase().endsWith(".jpg")) {
	            ximage = new PDJpeg(document, fis = new FileInputStream(image.getFile()));
	        }
	        else if (image.getName().toLowerCase().endsWith(".tif") || image.getName().toLowerCase().endsWith(".tiff")) {
	            ximage = new PDCcitt(document, raf = new RandomAccessFile(image.getFile(), "r"));
	        }
	        else {
	            BufferedImage awtImage = ImageIO.read(image.getFile());
	            ximage = new PDPixelMap(document, awtImage);
	        }
	        
	        PDPageContentStream contentStream = new PDPageContentStream(document, page, true, true);
	        contentStream.drawImage(ximage, 0, 0);
	        contentStream.close();
	        if (fis != null) {
	        	fis.close();
	        }
	        if (raf != null) {
	        	raf.close();
	        }
		}
		
		try {
			document.save(file);
		} catch (COSVisitorException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		// finally make sure that the document is properly
		// closed.
		document.close();		
	}