Package org.icepdf.core.pobjects

Examples of org.icepdf.core.pobjects.Page


  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();
View Full Code Here

TOP

Related Classes of org.icepdf.core.pobjects.Page

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.