PDF macro failed to generate the thumbnail image
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.
Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
Scanned PDF document that consists a single embedded image won't be displayed correctly in PDF macro on the Confluence page. However, PDF preview works as expected.
Environment
- Scanned PDF
Diagnosis
The following message appears in the atlassian-confluence.log
, when the PDF file view macro attempted to generate the thumbnail image and failed:
WARN [DefaultSlideCacheManager:thread-1] [conversion.convert.image.MemoryAwarePDFRenderer] drawImage Image of size 1656*2339 px dropped for memory protection
-- referer: http://localhost:8090/confluence/display/ct/testpage | url: /confluence/plugins/servlet/pptslide | traceId: a6c6cd1339882b25 | userName: admin
Cause
Image rendering takes an amount of memory and sometimes make the Confluence instance crash. To prevent the problem, Confluence then applied memory protection by design.
Workarounds
Option One (Preferred)
Convert the scanned documents into JPEG or PNG format instead of PDF.
Option Two
Please do take note that by performing this workaround and disabling the memory guard, you may hit into OutOfMemoryErrors if a high-resolution image is embedded in a PDF.
In Linux
- Open the setevn.sh from the Confluence installation folder
Add the below line:
setenv.shCATALINA_OPTS="-Dpdf.render.memory.guard.disabled=true ${CATALINA_OPTS}"
- Restart Confluence
- Navigate to the page, delete the original attachment to clear the corrupted thumbnail
- Re-attach it to the page
- Add the PDF macro to the page
In Windows, with Confluence running as a service
Identify the name of the service that Confluence is installed as in Windows (Go to Control Panel > Administrative Tools > Services)
We are expecting to see a service name like this Confluence251017164028
- Open the command window (Choose Start > cmd.exe)
cd to the bin directory of your Confluence installation folder and run the following command:
tomcat9w.exe //ES//%service_name%
- Click on the Java tab to see the list of current start-up options
In the Java Options box, add:
-Dpdf.render.memory.guard.disabled=true
Restart the service
For more details, please refer to Configuring System Properties - Windows service
- Navigate to the page, delete the original attachment to clear the corrupted thumbnail
- Re-attach it to the page
- Add the PDF macro to the page