No perfect answer, but a strategy to make a decision:
try (PDDocument document = PDDocument.load(new File(infile), password))
{
for (PDSignature sig : document.getSignatureDictionaries())
{
int[] byteRange = sig.getByteRange();
System.out.println("byteRange: " + Arrays.toString(byteRange));
System.out.println("Range max: " + (byteRange[byteRange.length-2] + byteRange[byteRange.length-1]));
// multiply content length with 2 (because it is in hex in the PDF) and add 2 for < and >
System.out.println("Content len: " + (sig.getCOSObject().getString(COSName.CONTENTS).length() * 2 + 2));
System.out.println("File len: " + new File(infile).length());
(...)
Now test this with this file. You'll get this output:
byteRange: [0, 192, 10094, 162062]
Range max: 172156
Content len: 9902
File len: 172156
The data that is signed starts at 0 with len 192, then the signature , then the rest of the data at 10094 with len 162062. You'll notice that 10094 + 162062 == 172156, and 192 + 9902 == 10094.
Of course if there are several signatures it won't look that perfect.