io.afu.utils.pdf.PDFUtils Maven / Gradle / Ivy
package io.afu.utils.pdf;
import io.afu.utils.files.FileUtils;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.rendering.PDFRenderer;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
public class PDFUtils {
public static void convertToImg(String pdfSavePath) throws Exception {
String fileNameWithoutSuffix = FileUtils.getFileNameWithoutSuffix(pdfSavePath);
File pdfFile = new File(pdfSavePath);
PDDocument document = null;
document = PDDocument.load(pdfFile);
PDFRenderer renderer = new PDFRenderer(document);
int numPages = document.getNumberOfPages();
if (numPages >1){
for (int i = 0;i1){
for (int i = 0;i