[#11126] - Transparent images in PDFs genereted by Jasper/iText are shown as red rectangle in Adobe Reader on Android

Category:
Bug report
Priority:
High
Status:
New
Project: Severity:
Major
Resolution:
Open
Component: Reproducibility:
Always
Assigned to:
3

Hello,
We're generating PDF Reports via JasperReports Framework (Version 6.3.1 with iText 2.1.7).
Recently we faced a problem with Adobe Reader on Android tablets: instead of the embedded images a ..red rectangle will be shown!

We noticed this problem for the first time with the Abrobat Reader Version 17.5.180092, and it still exists with the current version 18.2.0.182935.
(The Reader 17.0.* displays the PDFs correctly)
Displaying the same PDFs in Adobe Reader on all other platforms (Windows, iOS) with newest Reader Versions and with another PDF readers works without any problems.

A deeper investigation revealed that the reason is based on a transparent image, which was added by Jasper
(GIF loaded: net\sf\jasperreports\engine\images\pixel.GIF),
presumably used to position the image with user data.

On Android, the Acrobat Reader seems to display this image on top, in red color, and it obscures the graphic behind it.
In PDF editing tools (like Acrobat Pro) this transparent image can be captured and then moved, removed or set to background.
The PDF document looks fine in Adobe Reader on Android after this modification.

Is there any way to avoid this "behavior"?
Like forcing the transparent image to be invisible?
(Upgrading to newest version of Jasper: 6.6 didn't solve this problem)

We are grateful for any help.

--------------------
How we embed the graphics usually within jrxml:
<image scaleImage="RealSize">
<reportElement positionType="Float" x="0" y="27" width="609" height="50" backcolor="#FFFFFF"/>
<graphicElement>
<pen lineWidth="1.0"/>
</graphicElement>
<imageExpression class="net.sf.jasperreports.engine.JRRenderable"><![CDATA[$F{grafik}]]></imageExpression>
</image>

In Java we implemented a Renderer class as follows:
public class ReportGraphicRenderer extends AbstractRenderToImageDataRenderer {
@Override
public void render(JasperReportsContext jasperReportsContext, Graphics2D grx, Rectangle2D rectangle) {
// Do graphic operations
}
}

Christof

v6.3.1
ckux01's picture
2
Joined: Aug 22 2018 - 7:53am
Last seen: 2 years 8 months ago

4 Comments:

#1

Thanks to your brilliant analysis about pixel.gif I had the idea of replacing the gif with a png and that did the trick. So in my case I extended JrPDFExporter and overwrote getPxImage so that it returns a transparent PNG image.

#2
AttachmentSize
Image icon pepsi.png47.48 KB
#3

Is there any progress on this issue?

We have a similar problem with the 1x1 pixel image. As described above, we are also using the AbstractRenderToImageDataRenderer to convert a Graphics2D to a vector image that is used in the pdf. When inspecting the pdf in an editor like (acrobat, illustrator, corel draw), there is for every image we are creating, an additional overlapping transparent rectangle. It has the size 1x1 Pixel but it is stretched to the size of the image. This rectangle does not have a red border like descirbed above.

We are building a complex table using AbstractRenderToImageDataRenderer for each cell since this table and renderers will also be used on a java client. The resulting pdf has around 1000 pages so it is very big. Beside that, there is a manual postprocessing of the pdf made in a vector tool by a person.

If we could eliminate those transparent rectangles would help us very much to:
- reduce the file size (all compression tools we used so far do not delete those empty rectangles)
- increase the efficiency of the person that does the postprocessing (currently he must delete the overlapping rectangle first before he can change the underlying content)

#4

What is the status of this issue?

We are facing similar problems and would thus be interested in a fix.

Thanks

Feedback