2011-01-24 3 views
1

私はSWTで次のコードを実装しようとしていますが、私は大したことはありません。誰かが私にSWTでPdf-Renderライブラリを使う方法のヒントを教えてもらえますか?主な問題は、PagePanelをSWTシェルにアタッチする方法を考えることができないということです。 https://pdf-renderer.dev.java.net/examples.htmlSWTにJava Pdf-rendererのサンプルを実装する手助けがありますか?

おかげでから撮影

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 [email protected] 
*/ 
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(); 
       } 
      } 
     }); 
    } 
} 

答えて

0

...またはあなたはSWTをサポートjPodRendererを見ても...(GPL)

1

スイング/ SWTブリッジを使用できます。 eclipse.orgにはtutorialがあります。

0

あなたはお金を持っています。PdfONEを試してみてください。これは、より速く、埋め込まれたフォントにも対応できます。

0

また、Eclipse用の無料のPDFビューアプラグインであるhttp://www.jpedal.org/support_siEclipse.phpで見ることができます。フル・ワークスペース・プロジェクトを含むオープンソース・コードをダウンロードできます。

関連する問題