Uploaded image for project: 'PDFBox'
  1. PDFBox
  2. PDFBOX-3400

Gradient/Shading color alpha stepping do not work correctly

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • 1.8.12, 2.0.2
    • None
    • Parsing
    • Mac OS X, Maven repos

    Description

      Gradient created in illustrator with stepping to color with opacity do not render properly in PDFBox.
      Rectangle below sh added to test proper rendering.

      PDF (v 1.5, Adobe Illustrator CS5.1):
      http://u2.home.pl/gradients2.pdf

      Correct rendering (using pdf.js):
      http://u2.home.pl/correctrender.png

      PDFBox rendering (using PdfRenderer.renderImageWithDPI):
      http://u2.home.pl/pdfboxresult.png

      What I noticed is that pdf.js have two sh operands during parsing, when PDFBox returns one via PDFGraphicsStreamEngine.

      Tested on 2.0.2 and 1.8.12.

      Code used to generate pdfboxresult.png:
      import org.apache.pdfbox.pdmodel.PDDocument;
      import org.apache.pdfbox.rendering.ImageType;
      import org.apache.pdfbox.rendering.PDFRenderer;
      import org.apache.pdfbox.tools.imageio.ImageIOUtil;
      import java.awt.image.BufferedImage;
      import java.io.*;

      public class Test {
      public static void main(String[] args) throws IOException {
      PDDocument document = PDDocument.load(new File("gradients2.pdf"));
      PDFRenderer pdfRenderer = new PDFRenderer(document);
      for (int page = 0; page < document.getNumberOfPages(); ++page)

      { BufferedImage bim = pdfRenderer.renderImageWithDPI(page, 300, ImageType.ARGB); ImageIOUtil.writeImage(bim, "pdfboxresult.png", 300); break; }

      document.close();
      }
      }

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              coobers Jedrzej Majko
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: