Setar tamanho PDFPagePanel do PDFBox

1 resposta
E

Boa tarde pessoas,

estou abrindo uma página de PDF em um JFrame utilizando a API do PDFBox. Até aí tudo bem, o problema está em conseguir aumentar o tamanho do PDFPagePanel (que herda de JPanel). Como fica pequeno, em alguns arquivos PDF a fonte fica muito ruim.
Como eu faria pra aumentar o tamanho desse PDFPagePanel?

Segue meu código abaixo:

package pdfbox;

import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.File;
import java.io.IOException;
import java.util.List;
import javax.swing.JFrame;
import org.apache.pdfbox.pdfviewer.PDFPagePanel;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDPage;

public class PDFBox extends PDFPagePanel {

    public PDFBox() throws IOException {
    }

    private void init() {
        JFrame jFrame = new JFrame();

        jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        try {
            final PDDocument doc = PDDocument.load(new File("C:\\AV3200U+.pdf"));
            List<PDPage> allPages = doc.getDocumentCatalog().getAllPages();
            PDPage page = (PDPage) allPages.get(1);
            setPage(page);
            
            jFrame.setBackground(Color.DARK_GRAY);
            
            setLayout(new FlowLayout());
            jFrame.add(this);
            jFrame.setBounds(40, 40, getWidth() + 100, getHeight() + 50);
            jFrame.setVisible(true);
            jFrame.addWindowListener(new WindowAdapter() {

                @Override
                public void windowClosing(WindowEvent e) {
                    try {
                        doc.close();
                    } catch (IOException e1) {

                        e1.printStackTrace();
                    }
                }

            });

        } catch (IOException e) {
            System.out.println(e.toString());
        }
        //doc.close();
    }

    public static void main(String[] args) throws IOException {

        PDFBox PDFBox = new PDFBox();
        PDFBox.init();

    }

}

PS: não posso converter pra imagem, pois há arquivos PDF com 600 páginas ou mais, tornando o processo muito lento.

Grato desde já.

1 Resposta

E

Nadinha?

Criado 8 de abril de 2015
Ultima resposta 9 de abr. de 2015
Respostas 1
Participantes 1