Package com.sun.pdfview

Examples of com.sun.pdfview.PDFPage


                    } catch (IOException ioe) {
                        getClient().addMessage(DcResources.getText("msgCouldNotReadInfoFrom", filename));
                    }
   
                    // draw the first page to an image
                    PDFPage page = pdffile.getPage(0);
                    if (page != null) {
                        Rectangle rect = new Rectangle(0,0, (int)page.getBBox().getWidth(), (int)page.getBBox().getHeight());
                        Image front = page.getImage(rect.width, rect.height, rect, null, true, true);
                        book.setValue(Book._K_PICTUREFRONT, new DcImageIcon(Utilities.getBytes(new DcImageIcon(front))));
                    }
                } finally {
                    if (raf != null)
                        raf.close();
View Full Code Here


          pdffile = new PDFFile(buf, new PDFPassword(options.getPdfOwnerPwdStr()));
        }
      }

      // draw the page to an image
      PDFPage page = pdffile.getPage(aPage);

      // get the width and height for the doc at the default zoom
      Rectangle rect = new Rectangle(0, 0, (int) page.getBBox().getWidth(), (int) page.getBBox().getHeight());

      // generate the image
      tmpResult = (BufferedImage) page.getImage(rect.width, rect.height, rect, // clip
          // rect
          null, // null for the ImageObserver
          true, // fill background with white
          true // block until drawing is done
          );
View Full Code Here

  /**
   * create the image to load
   **/
  private Image getPageFromDisk(int pageNum) {
    PDFPage page = pdfFile.getPage(pageNum + 1);
    Rectangle2D r2d = page.getBBox();
    imageWidth = r2d.getWidth();
    imageHeight = r2d.getHeight();
    imageWidth /= PAGE_DIMENSION_RATIO;
    imageHeight /= PAGE_DIMENSION_RATIO;
    int res = Toolkit.getDefaultToolkit().getScreenResolution();
    imageWidth *= res;
    imageHeight *= res;
    return page.getImage((int) imageWidth, (int) imageHeight, r2d, null,
        true, true);
  }
View Full Code Here

            // glyph not found.  Return an empty glyph...
            return new PDFGlyph(src, name, new GeneralPath(), new Point2D.Float(0, 0));
        }

        try {
            PDFPage page = new PDFPage(bbox, 0);
            page.addXform(at);

            PDFParser prc = new PDFParser(page, pageObj.getStream(), rsrc);
            prc.go(true);

            float width = widths[src - firstChar];
View Full Code Here

            PDFObject bobj = obj.getDictRef("BBox");
            Float bbox = new Rectangle2D.Float(bobj.getAt(0).getFloatValue(),
                    bobj.getAt(1).getFloatValue(),
                    bobj.getAt(2).getFloatValue(),
                    bobj.getAt(3).getFloatValue());
            PDFPage formCmds = new PDFPage(bbox, 0);
            // stamp annotation transformation
            AffineTransform rectAt = getPositionTransformation();
            formCmds.addXform(rectAt);

            // form transformation
            AffineTransform at;
            PDFObject matrix = obj.getDictRef("Matrix");
            if (matrix == null) {
                at = new AffineTransform();
            } else {
                float elts[] = new float[6];
                for (int i = 0; i < elts.length; i++) {
                    elts[i] = (matrix.getAt(i)).getFloatValue();
                }
                at = new AffineTransform(elts);
            }
            formCmds.addXform(at);
           
            HashMap<String,PDFObject> r = new HashMap<String,PDFObject>(new HashMap<String, PDFObject>());
            PDFObject rsrc = obj.getDictRef("Resources");
            if (rsrc != null) {
                r.putAll(rsrc.getDictionary());
            }

            PDFParser form = new PDFParser(formCmds, obj.getStream(), r);
            form.go(true);

            result.addAll(formCmds.getCommands());
        } else {
            throw new PDFParseException("Unknown XObject subtype: " + type);
        }
        result.add(PDFPage.createPopCmd());
        result.add(PDFPage.createPopCmd());
View Full Code Here

            PDFObject bobj = obj.getDictRef("BBox");
            Float bbox = new Rectangle2D.Float(bobj.getAt(0).getFloatValue(),
                    bobj.getAt(1).getFloatValue(),
                    bobj.getAt(2).getFloatValue(),
                    bobj.getAt(3).getFloatValue());
            PDFPage formCmds = new PDFPage(bbox, 0);
            // stamp annotation transformation
            AffineTransform rectAt = getPositionTransformation();
            formCmds.addXform(rectAt);

            // form transformation
            AffineTransform at;
            PDFObject matrix = obj.getDictRef("Matrix");
            if (matrix == null) {
                at = new AffineTransform();
            } else {
                float elts[] = new float[6];
                for (int i = 0; i < elts.length; i++) {
                    elts[i] = (matrix.getAt(i)).getFloatValue();
                }
                at = new AffineTransform(elts);
            }
            formCmds.addXform(at);
           
            HashMap<String,PDFObject> r = new HashMap<String,PDFObject>(new HashMap<String, PDFObject>());
            PDFObject rsrc = obj.getDictRef("Resources");
            if (rsrc != null) {
                r.putAll(rsrc.getDictionary());
            }

            PDFParser form = new PDFParser(formCmds, obj.getStream(), r);
            form.go(true);

            result.addAll(formCmds.getCommands());
        } else {
            throw new PDFParseException("Unknown XObject subtype: " + type);
        }
        result.add(PDFPage.createPopCmd());
        result.add(PDFPage.createPopCmd());
View Full Code Here

                                                    getXStep(),
                                                    getYStep());
        //anchor = getTransform().createTransformedShape(anchor).getBounds2D();
       
        // now create a page bounded by the pattern's user space size
        final PDFPage page = new PDFPage(getBBox(), 0);
       
        // set the base paint if there is one
        if (basePaint != null) {
            page.addFillPaint(basePaint);
            page.addStrokePaint(basePaint);
        }
       
        // undo the page's transform to user space
        /*
        AffineTransform xform =
            new AffineTransform(1, 0, 0, -1, 0, getYStep());
            //new AffineTransform(1, 0, 0, -1, 0, getBBox().getHeight());
        page.addXform(xform);
        */
       
        // now parse the pattern contents
        PDFParser prc = new PDFParser(page, this.data, getResources());
        prc.go(true);
       
        int width = (int) getBBox().getWidth();
        int height = (int) getBBox().getHeight();
       
        // get actual image
        Paint paint = new Paint() {
            @Override
      public PaintContext createContext(ColorModel cm,
                                              Rectangle deviceBounds,
                                              Rectangle2D userBounds,
                                              AffineTransform xform,
                                              RenderingHints hints)
            {
                ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
                ColorModel model = new ComponentColorModel(cs,
                                                           true,
                                                           false,
                                                           Transparency.TRANSLUCENT,
                                                           DataBuffer.TYPE_BYTE);
          
                Rectangle2D devBBox =
                    xform.createTransformedShape(getBBox()).getBounds2D();
               
                double[] steps = new double[] { getXStep(), getYStep() };
                xform.deltaTransform(steps, 0, steps, 0, 1);
               
                int width = (int) Math.ceil(devBBox.getWidth());
                int height = (int) Math.ceil(devBBox.getHeight());
               
                BufferedImage img = (BufferedImage) page.getImage(width, height, 
                                                                  null, null,
                                                                  false, true);
                                                                 
                return new Type1PaintContext(model, devBBox,
                                             (float) steps[0],
View Full Code Here

            // glyph not found.  Return an empty glyph...
            return new PDFGlyph(src, name, new GeneralPath(), new Point2D.Float(0, 0));
        }

        try {
            PDFPage page = new PDFPage(this.bbox, 0);
            page.addXform(this.at);

            PDFParser prc = new PDFParser(page, pageObj.getStream(), this.rsrc);
            prc.go(true);

            float width = this.widths[src - this.firstChar];
View Full Code Here

   */
  public synchronized PDFPage loadPage(int pageNumber) {
    pageNumber--;
    if (busy[pageNumber]) return null;
    busy[pageNumber] = true;
    PDFPage page = file.getPage(pageNumber + 1, true);
    if (!done[pageNumber]) {
      System.out.println("Loading page " + (pageNumber + 1));
    }
    done[pageNumber] = true;
    busy[pageNumber] = false;
View Full Code Here

            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

TOP

Related Classes of com.sun.pdfview.PDFPage

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.