Converter .pdf para uma imagem

4 respostas
B

Aee galera to precisando converter um arquivo pdf para uma imagem !!
eu to usando itext mas posso usar outra ferramenta se for mais facil.
Alguem tem algum exemplo de codigo para me ajudar ?
valeu galera

4 Respostas

A

Aqui vai ... vai necessitar da lib PDFRender

Converte a 1 pagina, agora é so adaptar.

public  void getImage(String dir, String fileDir, String fileName) throws FileNotFoundException, IOException {
        File pdfFile = new File(fileDir);
       
        RandomAccessFile raf = new RandomAccessFile(pdfFile, "r");
        FileChannel channel = raf.getChannel();
        ByteBuffer buf = channel.map(FileChannel.MapMode.READ_ONLY, 0, channel.size());
        PDFFile pdf = new PDFFile(buf);
        PDFPage page = pdf.getPage(1);

        Rectangle rect = new Rectangle(0, 0, (int) page.getBBox().getWidth(),
                (int) page.getBBox().getHeight());
        BufferedImage bufferedImage = new BufferedImage(rect.width, rect.height,
                BufferedImage.TYPE_INT_RGB);

        Image image = page.getImage(rect.width, rect.height,
                rect, 
                null, 
                true, 
                true 
                );
        Graphics2D bufImageGraphics = bufferedImage.createGraphics();
        bufImageGraphics.drawImage(image, 0, 0, null);
        ImageIO.write(bufferedImage, "jpg", new File(dir + "imagem.jpg"));

    }

Alguem como fazer o mesmo para documentos do office?

B

Você sabe aonde eu baixo essa api ? nao consegui achar !

aonde que ele vai mandar o pdf pra transformar em imagem ?

B

To com essa duvida

Kanin_Dragon

Jovem,

Utilize http://findjar.com/index.x

abs,

Criado 20 de maio de 2011
Ultima resposta 20 de mai. de 2011
Respostas 4
Participantes 3