public static int getpages(String url) throws IOException, ServerException, InsufficientDataException, InternalException, InvalidResponseException, InvalidKeyException, NoSuchAlgorithmException, XmlParserException, ErrorResponseException { MinioClient minioClient = MinioClient.builder() .endpoint(minio_url) .credentials(accesskey,secretkey) .build(); GetObjectArgs fangxun = GetObjectArgs.builder().bucket(bucket).object(url).build(); InputStream inputStream = minioClient.getObject(fangxun); byte[] buffer = new byte[8192]; ByteArrayOutputStream baos = new ByteArrayOutputStream(); int bytesRead; while ((bytesRead = inputStream.read(buffer)) != -1) { baos.write(buffer, 0, bytesRead); } baos.flush(); PdfReader pdfReader = new PdfReader(baos.toByteArray()); int pages = pdfReader.getNumberOfPages(); return pages; }
minio下获取的pdf页数
最新推荐文章于 2024-04-19 09:50:43 发布