docs: public boolean check() throws Exception {
          try (PDDocument document = PDDocument.load(in)) {
              PDDocumentCatalog catalog = document.getDocumentCatalog();
              PDFPageable pageable = new PDFPageable(document);
              PageFormat firstPage = pageable.getPageFormat(0);
  
              encrypted = document.isEncrypted();
              pageCount = document.getNumberOfPages();
              orientation = ORIENTATION_STRINGS[firstPage.getOrientation()];
              version = String.valueOf(document.getDocument().getVersion());
              String catalogVersion = catalog.getVersion();
              if (catalogVersion != null && !catalogVersion.isEmpty()) {
                  // According to specs version saved here should be determining instead
                  // the version in header. It is barely used, though.
                  version = catalogVersion;
              }
  
              if (!encrypted) {
                  PDDocumentInformation metadata = document.getDocumentInformation();
                  author = metadata.getAuthor();
                  creationDate = metadata.getCreationDate();
                  creator = metadata.getCreator();
                  keywords = metadata.getKeywords();
                  modificationDate = metadata.getModificationDate();
                  producer = metadata.getProducer();
                  subject = metadata.getSubject();
                  title = metadata.getTitle();
              }
  
              // extract all attached files from all pages
              int pageNumber = 0;
              for (Object page : catalog.getPages()) {
                  pageNumber += 1;
                  PdfPageMetadata pageMetadata = new PdfPageMetadata();
                  pageMetadata.setPageNumber(pageNumber);
                  for (PDAnnotation annotation : ((PDPage) page).getAnnotations()) {
                      if (annotation instanceof PDAnnotationFileAttachment) {
                          PdfAttachmentMetadata attachmentMetadata = new PdfAttachmentMetadata();
  
                          PDAnnotationFileAttachment fann = (PDAnnotationFileAttachment) annotation;
                          PDComplexFileSpecification fileSpec = (PDComplexFileSpecification) fann.getFile();
                          PDEmbeddedFile embeddedFile = fileSpec.getEmbeddedFile();
  
                          attachmentMetadata.setSubject(fann.getSubject());
                          attachmentMetadata.setName(fileSpec.getFilename());
                          attachmentMetadata.setCreationDate(embeddedFile.getCreationDate());
                          attachmentMetadata.setModificationDate(embeddedFile.getModDate());
                          attachmentMetadata.setMimeType(embeddedFile.getSubtype());
                          attachmentMetadata.setData(embeddedFile.toByteArray());
  
                          pageMetadata.addAttachment(attachmentMetadata);
                      }
                  }
                  pages.add(pageMetadata);
              }
              return true;
          }
      }