Ciao a tutti,
ho un problema e siccome sono alle prime armi non so come risolverlo...sto facendo molta confusione.
Allora devo visualizzare le pagine di un manuale, riesco a visualizzare la prima ma non so come fare a visualizzare le altre.
Credo che bisognerà creare un arraylist, inserire le pagine e visualizzarle poi con due pulsanti AVANTI e INDIETRO si dovrebbe scorrere le pagine..... solo che non ho idea di come si faccia!!!
Potreste aiutarmi per favore????
questo è il codice che fin'ora ho fatto....
package jmt.pdf;
import java.awt.*;
import java.awt.event.ActionListener;
import java.awt.geom.*;
import java.io.*;
import java.nio.*;
import java.nio.channels.*;
import javax.swing.*;
import com.sun.pdfview.*;
import com.sun.pdfview.action.GoToAction;
import java.util.ArrayList;
import java.util.Collection;
public class PDFViewer extends JFrame {
static Image image;
public PDFViewer(String title) {
super(title);
setDefaultCloseOperation(EXIT_ON_CLOSE);
JLabel label = new JLabel(new ImageIcon(image));
label.setVerticalAlignment(JLabel.TOP);
setContentPane(new JScrollPane(label));
pack();
setVisible(true);
}
public static void showManual(ManualBookmarkers marker) throws IOException {
// RandomAccessFile raf = new RandomAccessFile(new File(PDFViewer.class
// .getResource("manual.pdf").getFile()), "r");
RandomAccessFile raf = new RandomAccessFile(new File("c:\\manual.pdf"), "r");
FileChannel fc = raf.getChannel();
ByteBuffer buf = fc.map(FileChannel.MapMode.READ_ONLY, 0, fc.size());
PDFFile pdfFile = new PDFFile(buf);
int pageNum = 1;
int pageNum2 = 1;
OutlineNode on = (OutlineNode) pdfFile.getOutline();
if (on != null) {
for (int i = 0; i < on.getChildCount(); i++) {
OutlineNode child = (OutlineNode) on.getChildAt(i);
if (child.getAction() instanceof GoToAction) {
GoToAction act = (GoToAction) child.getAction();
if (child.toString().equals(marker.toString())) {
pageNum =pdfFile.getPageNumber(act.getDestination().getPag e());
}
if (child.toString().equals(ManualBookmarkers.JABA.to String())) {
pageNum2 =pdfFile.getPageNumber(act.getDestination().getPag e());
System.out.print(pageNum2);
}
}
}
PDFPage page = pdfFile.getPage(pageNum+1);
System.out.println(page);
Rectangle2D r2d = page.getBBox();
double width = r2d.getWidth();
double height = r2d.getHeight();
width /= 72.0;
height /= 72.0;
int res = Toolkit.getDefaultToolkit().getScreenResolution();
width *= res;
height *= res;
}
Vi ringrazio anticipatamente......