当前位置: 首页 > 工具软件 > ICEpdf > 使用案例 >

icepdf

汲丰茂
2023-12-01
import java.awt.image.BufferedImage;
import java.awt.image.RenderedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import org.icepdf.core.pobjects.Document;
import org.icepdf.core.pobjects.Page;
import org.icepdf.core.util.GraphicsRenderingHints;
 
public class PDFtopng{
    public static void main(String args[]) {
    	String filePath = "F:\\*.pdf";
        Document document = new Document();
        try {
            document.setFile(filePath);
        	} catch (Exception ex) {
        }
        float scale = 1.3f;
        float rotation = 0f;
        for (int i = 0; i < document.getNumberOfPages(); i++) {
            BufferedImage image = (BufferedImage)
            document.getPageImage(i,GraphicsRenderingHints.SCREEN,Page.BOUNDARY_CROPBOX, rotation, scale);
            RenderedImage rendImage = image;
            try {
                File file = new File("F:\\png_" + i + ".png");
                ImageIO.write(rendImage, "png", file);
            	} catch (IOException e) {
                e.printStackTrace();
            }
            image.flush();
 
        }
        document.dispose();
    }
}

 

 类似资料:

相关阅读

相关文章

相关问答