帮助在SWT中实现Java Pdf渲染器示例?

帮助在SWT中实现Java Pdf渲染器示例?,java,swing,pdf,swt,pdfrenderer,Java,Swing,Pdf,Swt,Pdfrenderer,我试图在SWT中实现以下代码,但运气不太好。有人能给我一个关于如何使用SWT的Pdf渲染库的提示吗?我认为主要的问题是我无法解决如何将PagePanel连接到SWT外壳 package pdfpaneltest; import com.sun.pdfview.PDFFile; import com.sun.pdfview.PDFPage; import com.sun.pdfview.PagePanel; import java.io.*; import java.nio.ByteBuffer

我试图在SWT中实现以下代码,但运气不太好。有人能给我一个关于如何使用SWT的Pdf渲染库的提示吗?我认为主要的问题是我无法解决如何将PagePanel连接到SWT外壳

package pdfpaneltest;

import com.sun.pdfview.PDFFile;
import com.sun.pdfview.PDFPage;
import com.sun.pdfview.PagePanel;
import java.io.*;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import javax.swing.*;

/**
 * An example of using the PagePanel class to show PDFs. For more advanced
 * usage including navigation and zooming, look ad the 
 * com.sun.pdfview.PDFViewer class.
 *
 * @author joshua.marinacci@sun.com
 */
public class Main {

    public static void setup() throws IOException {

        //set up the frame and panel
        JFrame frame = new JFrame("PDF Test");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        PagePanel panel = new PagePanel();
        frame.add(panel);
        frame.pack();
        frame.setVisible(true);

        //load a pdf from a byte buffer
        File file = new File("test.pdf");
        RandomAccessFile raf = new RandomAccessFile(file, "r");
        FileChannel channel = raf.getChannel();
        ByteBuffer buf = channel.map(FileChannel.MapMode.READ_ONLY,
            0, channel.size());
        PDFFile pdffile = new PDFFile(buf);

        // show the first page
        PDFPage page = pdffile.getPage(0);
        panel.showPage(page);

    }

    public static void main(final String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                try {
                    Main.setup();
                } catch (IOException ex) {
                    ex.printStackTrace();
                }
            }
        });
    }
}
取自


谢谢

您可以使用Swing/SWT桥。eclipse.org上有一个链接。

您可以使用Swing/SWT桥。eclipse.org上有一个网站。

如果你有一些钱要花,试试PdfONE,它更快,也可以处理嵌入式字体。

如果你有一些钱要花,试试PdfONE,它更快,也可以处理嵌入式字体。

或者你可以看看支持SWT的jPodRenderer。。。(GPL)

…或者您可以看看支持SWT的jPodRenderer。。。(GPL)

您还可以查看Eclipse的免费PDF查看器插件。您可以下载包括完整工作区项目在内的开放源代码。

您还可以查看Eclipse的免费PDF查看器插件。您可以下载包括完整工作区项目在内的开放源代码