PNGDevice high cpu usage causing application to freeze up

We are trying to extract a region from a Pdf and convert it to image using the PNGDevice class (see code snippet below) when the call to processToBufferedImage is called the CPU reaches 100% and takes ~25 sec to return for one region. I also tried process () and JPEGDevice all of them behave the same. Fyi we have multiple regions to extract on the same page the system stops responding when this happens.
{
Rectangle pageRect = page.getPageRect(false);
// Create PNG device with specified attributesTEST2.pdf (57.5 KB)

    PngDevice pngDevice = new PngDevice();
    // Convert the cropped page and save the image to stream
    ByteArrayOutputStream imageOutputStream = new ByteArrayOutputStream();
    BufferedImage bufferedPageImage = pngDevice.processToBufferedImage(page);

    int x = (int) (zoneTextBox.getLlX() / pageRect.getWidth() * bufferedPageImage.getWidth());
    int y = (int) ((pageRect.getHeight() - zoneTextBox.getUrY()) / pageRect.getHeight() * bufferedPageImage.getHeight());
    int w = (int) ((zoneTextBox.getUrX() - zoneTextBox.getLlX()) / pageRect.getWidth() * bufferedPageImage.getWidth());
    int h = (int) ((zoneTextBox.getUrY() - zoneTextBox.getLlY()) / pageRect.getHeight() * bufferedPageImage.getHeight());

    BufferedImage croppedPageImage = bufferedPageImage.getSubimage(x, y, w, h);
    try {
        ImageIO.write(croppedPageImage, "png", imageOutputStream);
        return imageOutputStream.toByteArray();
    } catch (IOException ex) {
        ex.printStackTrace();
    } finally {
        try {
            imageOutputStream.close();
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }
    return null;
}

@danros,

The source code has unknown objects, e.g. zoneTextBox. Please review and send us the complete Java code file, and also let us know which Aspose.PDF for Java API version you are using.

you can skip the zoneTextBox and crop to any region on the document.
thanks

@danros,

We managed to replicate the problem of high CPU usage. An investigation has been logged under the ticket ID PDFNET-44849 in our bug tracking system. We have linked your post to this ticket and will keep you informed regarding any available updates.

Hi, any update on this issue and is there an ETA ?
Thanks,
Roshini

@danros,

The linked ticket ID PDFNET-44849 is pending for the analysis and not resolved yet. We will investigate as per the development schedules, and notify you once it is fixed.

we are experiencing the same problem. CPU usage goes to 100% for about 7 seconds per drawing.

The PDF’s are about 1MB each.

I have tried this line on two different servers. Both CPUs go to 100% for several seconds.

            thePngDevice.Process(doc.Pages(pageCount), imageStream)

Thank you

Derek Williams

@Derek_Berek

Thanks for contacting support.

The earlier logged issue has been resolved in latest version of the API i.e. Aspose.PDF for .NET 19.5. Would you please make sure that you are using latest version. In case you still face this issue, please share your sample PDF document with us. We will test the scenario in our environment and address it accordingly.