I’m using the following code, in Java:
Page firstPdfPage = pdfDocument.getPages().get_Item(1);
PageInfo pdfPageInfo = firstPdfPage.getPageInfo();
Dimension pdfDimension = new Dimension((int) pdfPageInfo.getWidth(), (int) pdfPageInfo.getHeight());
Dimension boundaryDimension = new Dimension(MAX_WIDTH_HEIGHT, MAX_WIDTH_HEIGHT);
Dimension scaledDimension = getScaledDimension(pdfDimension, boundaryDimension);
Resolution resolution = new Resolution(72);
JpegDevice jpegDevice = new JpegDevice(scaledDimension.width, scaledDimension.height, resolution, 80);
jpegDevice.process(firstPdfPage, renditionOutputStream);
Using Aspose PDF 25.11, this generates a black box for certain images for certain PDFs, see attached example files.
input.pdf (24.4 KB)
output.jpeg (1.2 KB)
The code above produces a correct image using version 24.11. Later versions show the broken behavior, so the bug is most likely introduced somewhere around that time.
Maybe this helps: this seems to happen for images in PDF’s that have been generated using
more specifically, a textbox with an image that has been added using
<<image [image_expression] -fitWidth>>
@edorasware
It looks like the problem is a regression introduced after version 24.11 – the same PDF that renders correctly with 24.11 is rendered as a black box when processed with 25.11 (and later).
What to do next
-
Create a minimal reproducible sample
-
Try an alternative image device
- Replace
JpegDevice with PngDevice (or BmpDevice) using the same dimensions and resolution.
- If the PNG is also black, the issue is not JPEG‑specific.
-
Check the PDF content
- Open the PDF in a viewer and verify that the image is inside a form‑XObject/text‑box (the Word “textbox with an image” scenario).
- Note whether the image uses a mask, transparency, or an unsupported color space.
-
Collect environment details
- Java version (e.g., 1.8, 11, 17).
- OS (Windows/Linux/macOS) and its version.
- Whether you are running the code in a container, IDE, or as a service.
-
Submit a support request
- Attach the original PDF, the black JPEG (and PNG if you tried), the console log, and the environment details.
- Mention that the same PDF works with 24.11 but fails with 25.11 and later, and reference the forum thread “Black box for certain images when doing PDF to Image conversion”.
The Aspose PDF team can reproduce the regression with the files you provide and will be able to issue a fix or a workaround in an upcoming release.
@edorasware
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): PDFJAVA-45688
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.