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


Java PDimension类代码示例

本文整理汇总了Java中org.icepdf.core.pobjects.PDimension的典型用法代码示例。如果您正苦于以下问题:Java PDimension类的具体用法?Java PDimension怎么用?Java PDimension使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PDimension类属于org.icepdf.core.pobjects包,在下文中一共展示了PDimension类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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

示例4: createSVG

import org.icepdf.core.pobjects.PDimension; //导入依赖的package包/类
/**
 * Creates a SVG character stream for the given <code>Document</code> and
 * <code>PageNumber</code>.
 *
 * @param pdfDocument Document containing the PDF data
 * @param pageNumber  page number of PDF content that will be rendered to SVG.
 *                    Zero-based index
 * @param out         character stream that the SVG data will be written to
 */
public static void createSVG(Document pdfDocument, int pageNumber, Writer out) {
    try {

        if (pdfDocument != null &&
                (pageNumber >= 0 && pageNumber < pdfDocument.getNumberOfPages())) {
            // Get a DOMImplementation
            DOMImplementation domImpl = GenericDOMImplementation.getDOMImplementation();
            // Create an instance of org.w3c.dom.Document
            org.w3c.dom.Document document = domImpl.createDocument(null, "svg",
                    null);
            // Create an instance of the SVG Generator
            SVGGraphics2D svgGenerator = new SVGGraphics2D(document);
            // Ask the test to render into the SVG Graphics2D implementation

            float userRotation = 0;
            float userZoom = 1;
            PDimension pdfDimension = pdfDocument.getPageDimension(pageNumber, userRotation, userZoom);
            svgGenerator.setSVGCanvasSize(pdfDimension.toDimension());

            pdfDocument.paintPage(pageNumber, svgGenerator,
                    GraphicsRenderingHints.PRINT,
                    Page.BOUNDARY_CROPBOX,
                    userRotation, userZoom);

            // Finally, stream out SVG to the standard output using UTF-8
            // character to byte encoding
            boolean useCSS = true;              // we want to use CSS style attribute
            //            File f=new File("a.svg");
            //            Writer out = new OutputStreamWriter(new FileOutputStream(f), "UTF-8");
            svgGenerator.stream(out, useCSS);
        }
    } catch (org.apache.batik.svggen.SVGGraphics2DIOException e) {
        logger.log(Level.SEVERE, "Error creating svg document.", e);
    }
}
 
开发者ID:pdf4j,项目名称:icepdf,代码行数:45,代码来源:SVG.java


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