// for unpacked / processed resources
// Decide which to do based on if we're reading from a file or not already
TikaInputStream tstream = TikaInputStream.cast(stream);
if (tstream != null && tstream.hasFile()) {
// File based, take that as a cue to use a temporary file
RandomAccess scratchFile = new RandomAccessFile(tmp.createTemporaryFile(), "rw");
pdfDocument = PDDocument.load(new CloseShieldInputStream(stream), scratchFile, true);
} else {
// Go for the normal, stream based in-memory parsing
pdfDocument = PDDocument.load(new CloseShieldInputStream(stream), true);
}