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

Michael updated PDFBOX-6003:
----------------------------
    Description: 
In our PDF processing flow, where a customer could upload multi-page PDFs in 
different versions and resolutions, we encountered an OutOfMemory problem. 

The issue was, that the size of one of the images of a signature in a PDF page 
was 38884 to 30200. As a result, "SampledImageReader.getStencilImage" was 
trying to allocate *~4.5GB* of memory to convert a *1.7MB* single page PDF to 
an image.

The initial page size from the PDFBox was 446 to 631 (points), the DPI for the 
image conversion was 200. 

Is there any reason for allocating the image buffer similar to the original 
image in the PDF? 
Wouldn't it be sufficient to follow the page size proportion and required DPI, 
and allocate an image buffer size accordingly?

 

!image-2025-05-06-13-21-19-246.png|width=1050,height=459!!image-2025-05-06-13-21-19-281.png|width=1002,height=570!!image-2025-05-06-13-21-19-327.png|width=994,height=593!

  was:
In our PDF processing flow, where a customer could upload multi-page PDFs in 
different versions and resolutions, we encountered an OutOfMemory problem. 

The issue was, that the size of one of the images of a signature in a PDF page 
was 38884 to 30200. As a result, "SampledImageReader.getStencilImage" was 
trying to allocate *~4.5GB* of memory to convert a *1.7MB* single page PDF to 
an image.

The initial page size from the PDFBox was 446 to 631, the DPI for the image 
conversion was 200. 

Is there any reason for allocating the image buffer similar to the original 
image in the PDF? 
Wouldn't it be sufficient to follow the page size proportion and required DPI, 
and allocate an image buffer size accordingly?

 

!image-2025-05-06-13-21-19-246.png|width=1050,height=459!!image-2025-05-06-13-21-19-281.png|width=1002,height=570!!image-2025-05-06-13-21-19-327.png|width=994,height=593!


> Render image with DPI memory optimisation
> -----------------------------------------
>
>                 Key: PDFBOX-6003
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-6003
>             Project: PDFBox
>          Issue Type: Wish
>          Components: Rendering
>    Affects Versions: 3.0.5 PDFBox
>            Reporter: Michael
>            Priority: Critical
>         Attachments: image-2025-05-06-13-21-19-246.png, 
> image-2025-05-06-13-21-19-281.png, image-2025-05-06-13-21-19-327.png
>
>
> In our PDF processing flow, where a customer could upload multi-page PDFs in 
> different versions and resolutions, we encountered an OutOfMemory problem. 
> The issue was, that the size of one of the images of a signature in a PDF 
> page was 38884 to 30200. As a result, "SampledImageReader.getStencilImage" 
> was trying to allocate *~4.5GB* of memory to convert a *1.7MB* single page 
> PDF to an image.
> The initial page size from the PDFBox was 446 to 631 (points), the DPI for 
> the image conversion was 200. 
> Is there any reason for allocating the image buffer similar to the original 
> image in the PDF? 
> Wouldn't it be sufficient to follow the page size proportion and required 
> DPI, and allocate an image buffer size accordingly?
>  
> !image-2025-05-06-13-21-19-246.png|width=1050,height=459!!image-2025-05-06-13-21-19-281.png|width=1002,height=570!!image-2025-05-06-13-21-19-327.png|width=994,height=593!



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: dev-h...@pdfbox.apache.org

Reply via email to