当前位置: 首页>>代码示例>>Java>>正文


Java PDimension.getWidth方法代码示例

本文整理汇总了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;

}
 
开发者ID:lucee,项目名称:Lucee4,代码行数:38,代码来源:PDF2ImageICEpdf.java

示例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;
        }
 
开发者ID:pdf4j,项目名称:icepdf,代码行数:32,代码来源:PageLoadingEvents.java

示例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;
}
 
开发者ID:pdf4j,项目名称:icepdf,代码行数:29,代码来源:WatermarkPageCapture.java


注:本文中的org.icepdf.core.pobjects.PDimension.getWidth方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。