public static PDImageXObject createFromStream(PDDocument document, InputStream stream)
            throws IOException
    {
        return createFromByteArray(document, stream.readAllBytes());
    }
@Test
    void testCreateFromStream256() throws IOException
    {
        try
        {
            PDDocument document = new PDDocument();
            InputStream stream = JPEGFactoryTest.class.getResourceAsStream("jpeg256.jpg");
            PDImageXObject ximage = JPEGFactory.createFromStream(document, stream);
            validate(ximage, 8, 344, 287, "jpg", PDDeviceGray.INSTANCE.getName());
            
            doWritePDF(document, ximage, TESTRESULTSDIR, "jpeg256stream.pdf");
            checkJpegStream(TESTRESULTSDIR, "jpeg256stream.pdf", JPEGFactoryTest.class.getResourceAsStream("jpeg256.jpg"));
        }
        catch (Throwable ex)
        {
            ex.printStackTrace();
            throw ex;
        }
    }