Search code examples
javaswingpdfpdfrenderer

PDFRenderer-full-0.9.1 How can I reset the PgePanel after Zoom in PDF


anyone who can help please, Here is my problem: this is the code I use to get the PDF to PagePanel:

File file = new File("C:\\mmmmm\\nnnnn\\nnn\\tutorial.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.useZoomTool(true);
        panel.showPage(page);

now my problem come when I zoom in using the mouse which is working good as I wished but when I try to select the second page and show it on the same PagePanel it is shown in previously zoom and I can't see everything on the page, I want to show the second page on the same Panel without being zoomed in.just like the first page before i zoom in. any help Thanks Guys.


Solution

  • Guys I came to figure out how to zoom out,from ComboBox event When I select the new page I did this:

    File file = new File("C:\\mmmmm\\nnnnn\\nnn\\tutorial.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.setClip(null);
            panel.useZoomTool(false);
            panel.showPage(page);
    

    and there I was able to get the new page without ZoomIn but then by doing this it disable useZoomTool so what I did is I added the way to check useZoomTool to true again.

    Sorry for my English I know is too broken but that's how I got it to work