ResourceResolver { @Deprecated public PdfImageXObject retrieveImage(String src) { PdfXObject image = retrieveImageExtended(src); if (image instanceof PdfImageXObject) { return (PdfImageXObject) image; } else { return null; } } ResourceResolver(String baseUri);  ResourceResolver(String baseUri, IResourceRetriever retriever); IResourceRetriever getRetriever(); ResourceResolver setRetriever(IResourceRetriever retriever); @Deprecated PdfImageXObject retrieveImage(String src); PdfXObject retrieveImageExtended(String src); @Deprecated InputStream retrieveStyleSheet(String uri); @Deprecated byte[] retrieveStream(String src); byte[] retrieveBytesFromResource(String src); InputStream retrieveResourceAsInputStream(String src); boolean isDataSrc(String src); URL resolveAgainstBaseUri(String uri); void resetCache(); @Deprecated boolean isImageTypeSupportedByImageDataFactory(String src); static final String BASE64IDENTIFIER; static final String DATA_SCHEMA_PREFIX; }
@Test public void retrieveImageTest() { String fileName = "resourceResolverTest.png"; ResourceResolver resourceResolver = new ResourceResolver(baseUri); PdfImageXObject image = resourceResolver.retrieveImage(fileName); Assert.assertNotNull(image); Assert.assertTrue(image.identifyImageFileExtension().equalsIgnoreCase("png")); }
@Test @LogMessages(messages = @LogMessage(messageTemplate = LogMessageConstant.UNABLE_TO_RETRIEVE_IMAGE_WITH_GIVEN_BASE_URI)) public void retrieveImageWrongPathTest() { String fileName = "/itextpdf.com/itis.jpg"; ResourceResolver resourceResolver = new ResourceResolver(baseUri); PdfImageXObject image = resourceResolver.retrieveImage(fileName); Assert.assertNull(image); }
@Test public void retrieveImageRightPathTest() { String fileName = "itextpdf.com/itis.jpg"; ResourceResolver resourceResolver = new ResourceResolver(baseUri); PdfImageXObject image = resourceResolver.retrieveImage(fileName); Assert.assertNotNull(image); Assert.assertTrue(image.identifyImageFileExtension().equalsIgnoreCase("jpg")); }
@Test public void retrieveImagePathWithSpacesTest() { String fileName = "retrieveImagePathWithSpaces.jpg"; ResourceResolver resourceResolver = new ResourceResolver(baseUri + "path with spaces/"); PdfImageXObject image = resourceResolver.retrieveImage(fileName); Assert.assertNotNull(image); }