Examples of PDFPage


Examples of com.sun.pdfview.PDFPage

            RandomAccessFile raf = new RandomAccessFile(new File(path), "r");
            FileChannel channel = raf.getChannel();
            ByteBuffer buf = channel.map(FileChannel.MapMode.READ_ONLY, 0,
                    channel.size());
            PDFFile pdffile = new PDFFile(buf);
            PDFPage page = pdffile.getPage(0, true);
            Rectangle2D bb = page.getBBox();
            int width = bb == null ? (int) page.getWidth() : (int) bb.getWidth();
            int height = bb == null ? (int) page.getHeight() : (int) bb.getHeight();
            Rectangle rect = new Rectangle(0, 0, width, height);
            BufferedImage img = (BufferedImage) page.getImage(rect.width,
                    rect.height, rect, null, true, true);

            return super.saveThumbnail(img);
        } catch (Throwable e) {
            System.gc();
View Full Code Here

Examples of com.sun.pdfview.PDFPage

  private List<AttachmentPage> openAllPages(PDFFile pdf) throws IOException {
    int numPages = pdf.getNumPages();
    List<AttachmentPage> res = newArrayListWithCapacity(numPages);

    for (int i = 1; i <= pdf.getNumPages(); i++) {
      PDFPage page = pdf.getPage(i);

      AttachmentPage attachPage = toAttachmentPage(page);

      res.add(attachPage);
    }
View Full Code Here

Examples of com.sun.pdfview.PDFPage

   */
  public synchronized Image getPage(int pageID, double size) {
    if (pageID < 1 || pageID > pageCount) {
      return null;
    }
    PDFPage page = pdfFileContent.getPage(pageID);
    Rectangle2D r2d = page.getBBox();

    final double width, height;
    if (r2d.getWidth() > r2d.getHeight()) {
      width = size;
      height = (int) (size / (r2d.getWidth() / r2d.getHeight()));
    }
    else {
      width = (int) (size / (r2d.getHeight() / r2d.getWidth()));
      height = size;
    }

    return page.getImage((int) width, (int) height, r2d, null, true, true);
  }
View Full Code Here

Examples of com.sun.pdfview.PDFPage

   */
  public synchronized Image getPage(int pageID, Rectangle rect, int viewMode) {
    if (pageID < 1 || pageID > pageCount) {
      return null;
    }
    PDFPage page = pdfFileContent.getPage(pageID);
    Rectangle2D r2d = page.getBBox();
    double width = r2d.getWidth();
    double height = r2d.getHeight();
    width /= 72.0;
    height /= 72.0;
    int res = Toolkit.getDefaultToolkit().getScreenResolution();
    width *= res;
    height *= res;

    double f = getSizeFactorFromViewMode(width, height, rect, viewMode);
    width /= f;
    height /= f;

    return page.getImage((int) width, (int) height, r2d, null, true, true);
  }
View Full Code Here

Examples of com.sun.pdfview.PDFPage

    try{
      copy(input,file);
      PDFFile pdffile = toPDFFile(file);
     
          // draw a single page to an image
      PDFPage page = pdffile.getPage(pageNumber);
         
          return toImage(page,(int)page.getBBox().getWidth(),(int)page.getBBox().getHeight(),false);
       
   
    }
    finally{
      deleteEL(file);
View Full Code Here

Examples of com.sun.pdfview.PDFPage

  }
 
  private static void writeImage(PDFFile pdf, int pageNumber, Resource destination,String format, int scale,
      boolean overwrite, boolean goodQuality, boolean transparent) throws PageException, IOException {
   
    PDFPage page = pdf.getPage(pageNumber);
   
    if(scale<1) throw new ExpressionException("scale ["+scale+"] should be at least 1");
   
    int width = (int)page.getBBox().getWidth();
    int height = (int)page.getBBox().getHeight();
    if(scale!=100){
      double s=(scale)/100d;
      width=  (int)((width)*s);
      height=  (int)((height)*s);
     
 
View Full Code Here

Examples of com.sun.pdfview.PDFPage

        }
        final List<Image> list = new ArrayList<Image>();

        for (int i = 1; i <= pdfFile.getNumPages(); i++) {
            // Retrieve page i from document
            final PDFPage page = pdfFile.getPage(i);
            final Rectangle2D r2d = page.getBBox();

            // Prepare page scaling according to systems default DPI
            double width = r2d.getWidth();
            double height = r2d.getHeight();
            width /= DEFAULT_DPI;
            height /= DEFAULT_DPI;

            // Determine current screen DPI and scale the image accordingly
            final int res = Toolkit.getDefaultToolkit().getScreenResolution();
            width *= res * scaleFactor;
            height *= res * scaleFactor;

            // Add image to list
            list.add(page.getImage((int) width, (int) height, r2d, null, true,
                    true));
        }
        return list;
    }
View Full Code Here

Examples of com.sun.pdfview.PDFPage

            ByteBuffer buf = ByteBuffer.wrap(os.toByteArray());
            PDFFile pdffile = new PDFFile(buf);

            // show the first page
            XRLog.general("Page count: " + pdffile.getNumPages());
            PDFPage page = pdffile.getPage(0);
            pdfPanel.setZoom(-3.0);
            pdfPanel.showPage(page);
            lastRenderedHex = currentHex;

            XRLog.general("MD5 via BI: " + currentHex);
View Full Code Here

Examples of com.sun.pdfview.PDFPage

        // update the page text field
        pageField.setText(String.valueOf(curpage + 1));

        // fetch the page and show it in the appropriate place
        PDFPage pg = curFile.getPage(pagenum + 1);
        if (fspp != null) {
            fspp.showPage(pg);
            fspp.requestFocus();
        } else {
            page.showPage(pg);
View Full Code Here

Examples of com.sun.pdfview.PDFPage

            }

            if (waitforPage == curpage) {
                // don't go any further if the user changed pages.
                //                System.out.println("Preparer generating page " + (prepPage + 2));
                PDFPage pdfPage = curFile.getPage(prepPage + 1, true);
                if (pdfPage != null && waitforPage == curpage) {
                    // don't go any further if the user changed pages
                    //                    System.out.println("Generating image for page " + (prepPage + 2));

                    pdfPage.getImage(size.width, size.height, clip, null, true, true);
                //        System.out.println("Generated image for page "+ (prepPage+2));
                }
            }
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.