docs: public static int getPdfPageCount(File inputPdfFile) {
          //get Ghostscript instance
          Ghostscript gs = Ghostscript.getInstance();
  
          //prepare Ghostscript interpreter parameters
          //refer to Ghostscript documentation for parameter usage
          //gs -q -dNODISPLAY -c "(input.pdf) (r) file runpdfbegin pdfpagecount = quit"
          List<String> gsArgs = new ArrayList<String>();
          gsArgs.add("-gs");
          gsArgs.add("-dNOPAUSE");
          gsArgs.add("-dQUIET");
          gsArgs.add("-dNODISPLAY");
          gsArgs.add("-dBATCH");
          gsArgs.add("-c");
          String cValue = String.format("(%s) (r) file runpdfbegin pdfpagecount = quit", inputPdfFile.getPath().replace('\\', '/'));
          gsArgs.add(cValue);
  
          int pageCount = 0;
          ByteArrayOutputStream os;
  
          //execute and exit interpreter
          try {
              synchronized (gs) {
                  //output
                  os = new ByteArrayOutputStream();
                  gs.setStdOut(os);
                  gs.initialize(gsArgs.toArray(new String[0]));
                  pageCount = Integer.parseInt(os.toString().trim());
                  os.close();
              }
          } catch (UnsatisfiedLinkError e) {
              logger.error(e.getMessage());
              throw new RuntimeException(getMessage(e.getMessage()));
          } catch (NoClassDefFoundError e) {
              logger.error(e.getMessage());
              throw new RuntimeException(getMessage(e.getMessage()));
          } catch (GhostscriptException e) {
              logger.error(e.getMessage());
              throw new RuntimeException(e.getMessage());
          } catch (Exception e) {
              logger.error(e.getMessage());
          } finally {
              //delete interpreter instance (safer)
              try {
                  Ghostscript.deleteInstance();
              } catch (GhostscriptException e) {
                  //nothing
              }
          }
  
          return pageCount;
      }