gpt4 book ai didi

java - PDF 渲染器库中的缩放选项

转载 作者:行者123 更新时间:2023-12-01 16:02:22 26 4
gpt4 key购买 nike

我正在检查https://pdf-renderer.dev.java.net/的api我想将 PDF 转换为缩放级别为 100% 的图像。

有人尝试过吗?

最佳答案

    int widthPage  = (int)page.getBBox().getWidth();
int heightPage = (int)page.getBBox().getHeight();

if(page.getAspectRatio()<1){
widthPage = (int)(widthPage / page.getAspectRatio() );
heightPage = (int)(heightPage / page.getAspectRatio() );
}

// get the width and height for the doc at the default zoom
Rectangle rect = new Rectangle(0, 0, (int) widthPage, (int) heightPage);
// generate the image
Image img = page.getImage(rect.width, rect.height, // width & height
rect, // clip rect
null, // null for the ImageObserver
true, // fill background with white
true // block until drawing is done
);
// save it as a file

关于java - PDF 渲染器库中的缩放选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3507661/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com