本文整理汇总了Java中org.icepdf.core.pobjects.PDimension.getWidth方法的典型用法代码示例。如果您正苦于以下问题:Java PDimension.getWidth方法的具体用法?Java PDimension.getWidth怎么用?Java PDimension.getWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.icepdf.core.pobjects.PDimension
的用法示例。
在下文中一共展示了PDimension.getWidth方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toBufferedImage
import org.icepdf.core.pobjects.PDimension; //导入方法依赖的package包/类
private static BufferedImage toBufferedImage(Document document, int pageNumber,float scale,boolean transparent) {
System.getProperties().put("org.icepdf.core.screen.background", "VALUE_DRAW_NO_BACKGROUND");
Catalog cat = document.getCatalog();
Page page = cat.getPageTree().getPage(pageNumber-1, document);
PDimension sz = page.getSize(Page.BOUNDARY_CROPBOX, 0f, scale);
int pageWidth = (int) sz.getWidth();
int pageHeight = (int) sz.getHeight();
BufferedImage image = new BufferedImage(pageWidth,
pageHeight,
transparent?BufferedImage.TYPE_INT_ARGB:BufferedImage.TYPE_INT_RGB);
Graphics g = image.createGraphics();
if (!transparent) {
PRectangle pageBoundary = page.getPageBoundary(Page.BOUNDARY_CROPBOX);
float x = 0 - pageBoundary.x;
float y = 0 - (pageBoundary.y - pageBoundary.height);
g.setColor(Color.WHITE);
g.fillRect((int) (0 - x),
(int) (0 - y),
(int) pageBoundary.width,
(int) pageBoundary.height);
}
page.paint(g, GraphicsRenderingHints.SCREEN,
Page.BOUNDARY_CROPBOX, 0f, scale);
g.dispose();
cat.getPageTree().releasePage(page, document);
return image;
}
示例2: call
import org.icepdf.core.pobjects.PDimension; //导入方法依赖的package包/类
public Void call() {
Page page = document.getPageTree().getPage(pageNumber);
// assign a metrics page loading listener
page.addPageProcessingListener(new MetricsPageLoadingListener(
document.getNumberOfPages()));
page.init();
PDimension sz = page.getSize(Page.BOUNDARY_CROPBOX, rotation, scale);
int pageWidth = (int) sz.getWidth();
int pageHeight = (int) sz.getHeight();
BufferedImage image = new BufferedImage(pageWidth,
pageHeight,
BufferedImage.TYPE_INT_RGB);
Graphics g = image.createGraphics();
page.paint(g, GraphicsRenderingHints.PRINT,
Page.BOUNDARY_CROPBOX, rotation, scale);
g.dispose();
// capture the page image to file
// try {
// System.out.println("Capturing page " + pageNumber);
// File file = new File("imageCapture_" + pageNumber + ".png");
// ImageIO.write(image, "png", file);
//
// } catch (Throwable e) {
// e.printStackTrace();
// }
image.flush();
return null;
}
示例3: call
import org.icepdf.core.pobjects.PDimension; //导入方法依赖的package包/类
public Void call() {
Page page = document.getPageTree().getPage(pageNumber);
page.init();
PDimension sz = page.getSize(Page.BOUNDARY_CROPBOX, rotation, scale);
int pageWidth = (int) sz.getWidth();
int pageHeight = (int) sz.getHeight();
BufferedImage image = new BufferedImage(pageWidth,
pageHeight,
BufferedImage.TYPE_INT_RGB);
Graphics g = image.createGraphics();
page.paint(g, GraphicsRenderingHints.PRINT,
Page.BOUNDARY_CROPBOX, rotation, scale);
g.dispose();
// capture the page image to file
try {
System.out.println("Capturing page " + pageNumber);
File file = new File("imageCapture_" + pageNumber + ".png");
ImageIO.write(image, "png", file);
} catch (Throwable e) {
e.printStackTrace();
}
image.flush();
return null;
}