/** * Provide the image for stream. The stream must be image XObject. * * @param resources PDResources for the XObject. * @return A BufferedImage. */ public BufferedImage getImage(PDResources resources) { try { PDImageXObject imageXObject; if (isThumb) { imageXObject = PDImageXObject.createThumbnail(stream); } else { imageXObject = new PDImageXObject(new PDStream(stream), resources); } return imageXObject.getImage(); } catch (IOException e) { e.printStackTrace(); } return null; }
/** * Check that all XObject references in the PDResource of the page and in the Thumb entry are confirming to the * PDF/A specification. * * @param context the preflight context. * @param page the page to check. * @throws ValidationException */ protected void validateGraphicObjects(PreflightContext context, PDPage page) throws ValidationException { COSBase thumbBase = page.getCOSObject().getItem(PAGE_DICTIONARY_VALUE_THUMB); if (thumbBase != null) { try { if (thumbBase instanceof COSObject) { thumbBase = ((COSObject) thumbBase).getObject(); } PDXObject thumbImg = PDImageXObject.createThumbnail((COSStream)thumbBase); ContextHelper.validateElement(context, thumbImg, GRAPHIC_PROCESS); } catch (IOException e) { LOGGER.debug("Unable to read Thumb image", e); context.addValidationError(new ValidationError(ERROR_GRAPHIC_INVALID, "Unable to read Thumb image : " + e.getMessage())); } } }
/** * Check that all XObject references in the PDResource of the page and in the Thumb entry are confirming to the * PDF/A specification. * * @param context the preflight context. * @param page the page to check. * @throws ValidationException */ protected void validateGraphicObjects(PreflightContext context, PDPage page) throws ValidationException { COSBase thumbBase = page.getCOSObject().getItem(PAGE_DICTIONARY_VALUE_THUMB); if (thumbBase != null) { try { if (thumbBase instanceof COSObject) { thumbBase = ((COSObject) thumbBase).getObject(); } PDXObject thumbImg = PDImageXObject.createThumbnail((COSStream)thumbBase); ContextHelper.validateElement(context, thumbImg, GRAPHIC_PROCESS); } catch (IOException e) { context.addValidationError(new ValidationError(ERROR_GRAPHIC_INVALID, "Unable to read Thumb image : " + e.getMessage())); } } }
/** * Check that all XObject references in the PDResource of the page and in the Thumb entry are confirming to the * PDF/A specification. * * @param context the preflight context. * @param page the page to check. * @throws ValidationException */ protected void validateGraphicObjects(PreflightContext context, PDPage page) throws ValidationException { COSBase thumbBase = page.getCOSObject().getItem(PAGE_DICTIONARY_VALUE_THUMB); if (thumbBase != null) { try { if (thumbBase instanceof COSObject) { thumbBase = ((COSObject) thumbBase).getObject(); } PDXObject thumbImg = PDImageXObject.createThumbnail((COSStream)thumbBase); ContextHelper.validateElement(context, thumbImg, GRAPHIC_PROCESS); } catch (IOException e) { context.addValidationError(new ValidationError(ERROR_GRAPHIC_INVALID, "Unable to read Thumb image : " + e.getMessage())); } } }