pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lucas Satabin <lucas...@n7mm.org>
Subject Problem converting pdf pages to png images
Date Wed, 23 May 2012 13:31:55 GMT

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi all,

I am using pdfbox to convert pages from pdf files generated by pdflatex
to png files and I ran into a problem that was resolved in the past:
since the last update of my LaTeX distribution (texlive), pages
converted to png (or jpeg as well) are empty (only transparent image in
png, or black image in jpeg).
I used to work with pdfTeX-1.40.10 with which pdfbox worked like a charm
(see attached files pdf-ok.pdf and pdf-ok1.png) and since the update I
am using  pdfTeX-1.40.12 and the same code does not work anymore (see
attached files pdf-nok.pdf and pdf-nok1.png).

The code snippet I used for this is the following:

import java.awt.image.BufferedImage;
import java.io.File;

import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.util.PDFImageWriter;

public class Test {
  public static void main(String[] args) throws Exception {
    PDDocument docOk = PDDocument.load(new File("pdf-ok.pdf"));
    PDDocument docNok = PDDocument.load(new File("pdf-nok.pdf"));

    PDFImageWriter imagewriter = new PDFImageWriter();
    try {
      imagewriter.writeImage(docOk, "png", null, 1, 1, "pdf-ok",
BufferedImage.TYPE_INT_RGB, 100);
      imagewriter.writeImage(docNok, "png", null, 1, 1, "pdf-nok",
BufferedImage.TYPE_INT_RGB, 100);
    } finally {
      docOk.close();
      docNok.close();
    }
  }
}

I tried this with both version 1.6.0 and 1.7.0-SNAPSHOT from the trunk I
checked out today. The result is the same with both versions.
Am I doing something wrong?

I looked for this problem on the Internet and as far as I understood,
this problem was fixed in version 1.6.0 (correct me if I misunderstood it).
I also heard about jai_imageio in different places, but I am not really
excited about using it in my code...
So is this a problem in my code or a bug in pdfbox while handling this pdf?

Thank you in advance for any hint!

Regards,
Lucas
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEbBAEBAgAGBQJPvObLAAoJEFmOZwqS8OBNGjkH9Ay5kxXssvApvTz00L0St9NY
lfebCbaU/YpH1Iguy79mP22Xvvnx+VRw/Oizt1a3kVIbXoVXDud74IgnDOqSdxIn
3CgfGjebsoyPHtQFgPKJXrZwHLes3AW2KG6TJKRhhkEgACs7DcGB2kHDet+qhHBw
Xx8NwpB1mlF2Q349YjX+9nq0hnZuXDQmIUV6pO7d3k8lnqXgQ7gJrtKdTAhXFbAo
SDhoVrxEJbvR8El8ChdA/s1FyjMVcsXI6pvamVS5v1JNHjKcAHi027+UDRUQ6XUh
F3bOJSJGNt8lAJhvbgouhtDtU+MBLPhcHc1U5TpPzfQiaJ5SPIOQyOScTas2ow==
=BBZE
-----END PGP SIGNATURE-----


Mime
View raw message