1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
   | import javax.swing.JInternalFrame;
 
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.*;
 
public class FicheIFrame extends JInternalFrame{
	public FicheIFrame(){
		super("Fiches de spécifications", 
				false, //resizable
	              false, //closable
	              true, //maximizable
	              false);//iconifiable
 
		 setSize(357,265);
		 setLocation(300,0);
		 run();
 
	}
	 public void setup() throws IOException {
		 PagePanel panel = new PagePanel();
		 this.add(panel);
		 File file = new File("D:/users/horel/eclipse/workspace/Project/bin/pdf/BDCarto.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);
	        PDFPage page = pdffile.getPage(0);
	        panel.showPage(page);
	 }
	 public void run() {
         try {
         	setup();
         } catch (IOException ex) {
             ex.printStackTrace();
         }
     }
 ;
} | 
Partager