Package com.sun.pdfview

Examples of com.sun.pdfview.PDFFile


  private PDFFile toPDFFile(File file) throws IOException {
    RandomAccessFile raf = new RandomAccessFile(file, "r");
        FileChannel channel = raf.getChannel();
        ByteBuffer buf = channel.map(FileChannel.MapMode.READ_ONLY, 0, channel.size());
        return new PDFFile(buf);

  }
View Full Code Here


        if (scaleFactor <= 0 || pdfData == null) {
            throw new IllegalArgumentException(
                    "Invalid scale factor (must be greater than zero) or PDF data (must not be null)");
        }
        final ByteBuffer buf = ByteBuffer.wrap(pdfData.getByteArray());
        PDFFile pdfFile;
        try {
            pdfFile = new PDFFile(buf);
        } catch (final IOException e) {
            throw new IllegalArgumentException(e.getMessage());
        }
        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();
View Full Code Here

        if (jobName == null) {
            jobName = "";
        }
        try {
            final ByteBuffer bb = ByteBuffer.wrap(pdf.getByteArray());
            final PDFFile pdfFile = new PDFFile(bb); // Create PDF Print Page
            final PDFPrintPage printPages = new PDFPrintPage(pdfFile); // Create
            // Print
            // Job
            final PrinterJob pjob = PrinterJob.getPrinterJob();
            final PageFormat pf = PrinterJob.getPrinterJob().defaultPage();

            // Format for DIN A4 page size
            final Paper paper = new Paper();
            paper.setSize(595.275591, 841.889764); // width, height of DIN-A4 at
            // 72dpi
            paper.setImageableArea(0, 0, paper.getWidth() * 2,
                    paper.getHeight());
            pf.setPaper(paper);

            pjob.setJobName(jobName);
            final Book book = new Book();
            book.append(printPages, pf, pdfFile.getNumPages());
            pjob.setPageable(book); // Send print job to default printer
            if (pjob.printDialog()) {
                pjob.print();
                return true;
            }
View Full Code Here

            renderer.createPDF(os);
            os.flush();


            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

        try {

            FileInputStream fis = new FileInputStream(file);
            FileChannel fc = fis.getChannel();
            ByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, fc.size());
            PDFFile pdfFile = new PDFFile(bb); // Create PDF Print Page
            PDFPrintPage pages = new PDFPrintPage(pdfFile);

// Create Print Job
            PrinterJob pjob = PrinterJob.getPrinterJob();
            PageFormat pf = PrinterJob.getPrinterJob().defaultPage();
            pjob.setJobName(file.getName());
            Book book = new Book();
            book.append(pages, pf, pdfFile.getNumPages());
            pjob.setPageable(book);

            if (pjob.printDialog()) {
                pjob.print();
            }
View Full Code Here

     * @param path
     */
    private void openPDFByteBuffer(ByteBuffer buf, String path, String name) {

        // create a PDFFile from the data
        PDFFile newfile = null;
        try {
            newfile = new PDFFile(buf);
        } catch (IOException ioe) {
            openError(path + " doesn't appear to be a PDF file.");
            return;
        }

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

            renderer.createPDF(os);
            os.flush();


            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

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.