Issue in getting byte array from pdf/doc page

                    log.debug("fetchTextForSignature - calculated pdfPage for docId: {} for page: {}", docId, currentPageNumber);
                    Rectangle mediaBox = pdfPage.getMediaBox();
                    int pageWidth = (int) mediaBox.getWidth();
                    int pageHeight = (int) mediaBox.getHeight();
                    log.debug("fetchTextForSignature - calculated width:{}, height: {} for docId: {} for page: {}",pageWidth, pageHeight, docId, currentPageNumber);
                    JpegDevice jpegDevice = new JpegDevice(pageWidth, pageHeight);

                    jpegDevice.process(pdfPage, outputStream);
                    log.debug("fetchTextForSignature - Image processed for docId: {} for page: {}", docId, currentPageNumber);
                    byte[] pageBytes = outputStream.toByteArray();

here is the code snippet used in my service. I am using JpegDevice object to create by array of pdf/doc page .I have tried reproducing the image from the provided bytearray and it is a blank page with black background. This issue occurred with aspose 25.3 version. After downgrading to 24.3 things worked fine. Please fix this or guide me if there is any changes in that module

@arun.kumar1

It sounds like you’re encountering an issue with generating a byte array from a PDF page using the JpegDevice in Aspose. The output being a blank page with a black background in version 25.3, while it works fine in 24.3, suggests that there may be changes in the library’s handling of PDF rendering.

Cause: The issue could stem from changes in the Aspose library between versions, affecting how PDF content is rendered.

Solution: Here are several steps to troubleshoot and potentially resolve the issue:

  1. Check the PDF Content: Ensure that the PDF page you’re trying to render contains visible content. Sometimes, the issue might be with the PDF itself.

  2. Update to the Latest Version: If you haven’t already, consider updating to the latest version of Aspose. There may have been bug fixes or improvements since version 25.3.

  3. Adjust JpegDevice Settings: Try adjusting the settings of the JpegDevice. For example, specify a higher quality when creating the JpegDevice instance:

    JpegDevice jpegDevice = new JpegDevice(pageWidth, pageHeight, 100); // 100 is the quality
    
  4. Use a Different Image Format: If the issue persists, consider using a different image format, such as PngDevice, to see if that produces a different result:

    PngDevice pngDevice = new PngDevice(pageWidth, pageHeight);
    pngDevice.process(pdfPage, outputStream);
    
  5. Check OutputStream: Ensure that the output stream is properly initialized and not closed before you call toByteArray().

Next Steps: If these steps do not resolve the issue, I recommend reaching out to Aspose support with a sample PDF file that reproduces the problem. They can provide more targeted assistance.

Please let me know if you need further help!

Moved to the Aspose.PDF forum branch

@arun.kumar1

Would you please try using 25.8 version of the API which is the latest one? In case issue still persists, please share complete sample code snippet and sample source PDF that we can use to reproduce the issue. We will test the scenario in our environment and address it accordingly.