Package com.sun.pdfview

Examples of com.sun.pdfview.PDFFile


                                                      ISBN.isISBN13(s) ? s : null);
                }
               
               
                RandomAccessFile raf = null;
                PDFFile pdffile;
                try {
                   
                    raf = new RandomAccessFile(file, "r");
                    FileChannel channel = raf.getChannel();
                    ByteBuffer buf = channel.map(FileChannel.MapMode.READ_ONLY, 0, channel.size());
                    pdffile = new PDFFile(buf);
                    pdffile.stop(1);
   
                    try {
                        book.setValue(Book._T_NROFPAGES, Long.valueOf(pdffile.getNumPages()));
                        Iterator<String> it = pdffile.getMetadataKeys();
                        while (it.hasNext()) {
                            String key = it.next();
                            String value = pdffile.getStringMetadata(key);
                           
                            if (!Utilities.isEmpty(value)) {
                                if (key.equalsIgnoreCase("Author"))
                                    DataManager.createReference(book, Book._G_AUTHOR, value);
                                if (key.equalsIgnoreCase("Title") && !value.trim().equalsIgnoreCase("untitled"))
                                    book.setValue(Book._A_TITLE, value);
                            }
                        }
                    } 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))));
                    }
View Full Code Here


      // load a pdf from a byte buffer
      File file = new File(options.getInFile());
      RandomAccessFile raf = new RandomAccessFile(file, "r");
      FileChannel channel = raf.getChannel();
      ByteBuffer buf = channel.map(FileChannel.MapMode.READ_ONLY, 0, channel.size());
      PDFFile pdffile = null;
      try {
        // try to read PDF without password
        pdffile = new PDFFile(buf);
      } catch (PDFParseException ppe) {
        try {
          // try to read PDF with empty password
          pdffile = new PDFFile(buf, new PDFPassword(""));
        } catch (PDFParseException ppe2) {
          // try to read PDF with owner password
          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
View Full Code Here

    raf = new RandomAccessFile(manualFile, "r");

    FileChannel fc = raf.getChannel();
    ByteBuffer buf = fc.map(FileChannel.MapMode.READ_ONLY, 0, fc.size());
    pdfFile = new PDFFile(buf);

    pageStart = 0;
    pageEnd = pdfFile.getNumPages();
    OutlineNode on = pdfFile.getOutline();
    if (on != null) {
View Full Code Here

      pdf = workAround();
    }
    // reading the file into SUN's PDFFile
    pdf.reOpen();
    try {
      PDFFile = new PDFFile(pdf.getNioByteBuffer());
    }
    catch(IOException ioe) {
      PDFFile = new PDFFile(workAround().getNioByteBuffer());
    }
    pdf.close();
   
  }
View Full Code Here

        try {
            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,
View Full Code Here

    try {

      channel = openFileChannel();

      PDFFile pdf = openPdfFile(channel);

      List<AttachmentPage> res = openAllPages(pdf);

      return res;
View Full Code Here

    return stream.getChannel();
  }

  private PDFFile openPdfFile(FileChannel channel) throws IOException {
    ByteBuffer buf = channel.map(FileChannel.MapMode.READ_ONLY, 0, channel.size());
    return new PDFFile(buf);
  }
View Full Code Here

    try {
      pdfFile = pdfFile2view;
      RandomAccessFile raf = new RandomAccessFile(pdfFile2view, "r");
      FileChannel fc = raf.getChannel();
      ByteBuffer buf = fc.map(FileChannel.MapMode.READ_ONLY, 0, fc.size());
      pdfFileContent = new PDFFile(buf);
      raf.close();
      pageCount = pdfFileContent.getNumPages();
    }
    catch (IOException ioe) {
      LogUtils.log(ioe);
View Full Code Here

   
    File file = File.createTempFile("pdf2img", "pdf");
   
    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);
       
   
    }
View Full Code Here

   

    File file = File.createTempFile("pdf2img", "pdf");
    try{
      copy(input,file);
      PDFFile pdf = toPDFFile(file);
   
      Resource res;
      int count = pdf.getNumPages();
      
      for(int page=1;page<=count;page++) {
        if(pages!=null && !pages.contains(Integer.valueOf(page)))continue;
        res=createDestinationResource(outputDirectory,prefix,page,format,overwrite);
        //res=outputDirectory.getRealResource(prefix+"_page_"+page+"."+format);
View Full Code Here

TOP

Related Classes of com.sun.pdfview.PDFFile

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.