You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "John Hewson (JIRA)" <ji...@apache.org> on 2014/10/14 10:50:34 UTC

[jira] [Updated] (PDFBOX-1206) PdfToImage no longer works as expected with jdk/java 7; image quality problem

     [ https://issues.apache.org/jira/browse/PDFBOX-1206?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

John Hewson updated PDFBOX-1206:
--------------------------------
    Description: 
I've done a extensive testing of pdfbox under the new Java 7, update 1 & update 2 releases, and am noticing
severe image quality issues when converting a pdf to an image.

Attached is the same pdf turned converted to an image under Java 6, then again with Java 7
with the same code. The Java 7 version looks pretty bad.

This is with jdk 1.7 update 1 & 2 (for solaris x64, running headless, and OS X running Java 7 preview update 2 with default with no addition vm args to the default java command). I've also tested against
the latest code in svn (the images below are from the most current version).

The good image below is from a recent version of the jdk 1.6 (and it has always looked good
on at least jdk1.5+).

To test, I used code like this:
{code}
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDPage;

public final class PdfToImageTest {

  public static BufferedImage toBufferedImage(final String pdfFile, final int resolution)
    throws IOException {
    PDDocument document = null;
    try {
      document = PDDocument.load(pdfFile);
      final PDPage page = (PDPage) document.getDocumentCatalog().getAllPages().get(0);
      final BufferedImage result = page.convertToImage(BufferedImage.TYPE_INT_ARGB, resolution);
      return result;
    } finally {
      if (document != null) {
        document.close();
      }
    }
  }

  public static void main (String[] args) throws IOException {
    ImageIO.write(toBufferedImage(args[0], 108), "png", new File(args[1]));
  }

}


  was:
I've done a extensive testing of pdfbox under the new Java 7, update 1 & update 2 releases, and am noticing
severe image quality issues when converting a pdf to an image.

Attached is the same pdf turned converted to an image under Java 6, then again with Java 7
with the same code. The Java 7 version looks pretty bad.

This is with jdk 1.7 update 1 & 2 (for solaris x64, running headless, and OS X running Java 7 preview update 2 with default with no addition vm args to the default java command). I've also tested against
the latest code in svn (the images below are from the most current version).

The good image below is from a recent version of the jdk 1.6 (and it has always looked good
on at least jdk1.5+).

To test, I used code like this:

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDPage;

public final class PdfToImageTest {

  public static BufferedImage toBufferedImage(final String pdfFile, final int resolution)
    throws IOException {
    PDDocument document = null;
    try {
      document = PDDocument.load(pdfFile);
      final PDPage page = (PDPage) document.getDocumentCatalog().getAllPages().get(0);
      final BufferedImage result = page.convertToImage(BufferedImage.TYPE_INT_ARGB, resolution);
      return result;
    } finally {
      if (document != null) {
        document.close();
      }
    }
  }

  public static void main (String[] args) throws IOException {
    ImageIO.write(toBufferedImage(args[0], 108), "png", new File(args[1]));
  }

}



> PdfToImage no longer works as expected with jdk/java 7; image quality problem
> -----------------------------------------------------------------------------
>
>                 Key: PDFBOX-1206
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-1206
>             Project: PDFBox
>          Issue Type: Bug
>          Components: Rendering
>    Affects Versions: 1.6.0, 1.7.0
>         Environment: All (tested on OS X and Solaris but believe it affects all platforms), tested java 7 update 1 & update 2
>            Reporter: Armando Singer
>              Labels: convertToImage, image
>             Fix For: 2.0.0
>
>         Attachments: convertToImage.pdf, converttoimage.pdf-1.png
>
>
> I've done a extensive testing of pdfbox under the new Java 7, update 1 & update 2 releases, and am noticing
> severe image quality issues when converting a pdf to an image.
> Attached is the same pdf turned converted to an image under Java 6, then again with Java 7
> with the same code. The Java 7 version looks pretty bad.
> This is with jdk 1.7 update 1 & 2 (for solaris x64, running headless, and OS X running Java 7 preview update 2 with default with no addition vm args to the default java command). I've also tested against
> the latest code in svn (the images below are from the most current version).
> The good image below is from a recent version of the jdk 1.6 (and it has always looked good
> on at least jdk1.5+).
> To test, I used code like this:
> {code}
> import java.awt.image.BufferedImage;
> import java.io.File;
> import java.io.IOException;
> import javax.imageio.ImageIO;
> import org.apache.pdfbox.pdmodel.PDDocument;
> import org.apache.pdfbox.pdmodel.PDPage;
> public final class PdfToImageTest {
>   public static BufferedImage toBufferedImage(final String pdfFile, final int resolution)
>     throws IOException {
>     PDDocument document = null;
>     try {
>       document = PDDocument.load(pdfFile);
>       final PDPage page = (PDPage) document.getDocumentCatalog().getAllPages().get(0);
>       final BufferedImage result = page.convertToImage(BufferedImage.TYPE_INT_ARGB, resolution);
>       return result;
>     } finally {
>       if (document != null) {
>         document.close();
>       }
>     }
>   }
>   public static void main (String[] args) throws IOException {
>     ImageIO.write(toBufferedImage(args[0], 108), "png", new File(args[1]));
>   }
> }



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)