Free Support Forum - groupdocs.com

GetPageCount return 0 for PNG / JPG


#1

Hello,


I tried to get page count by given array of byte (JPG/PNG), Expected result should be 1, instead I am getting 0.

bais = new ByteArrayInputStream(array);
int totalPages = conversionHandler.getPageCount(bais, fileName);

Thanks.

#2
Hello,

Thank you for your inquiry.

Basically, current version of the GroupDocs.Conversion for Java library counts the pages beginning from 0, but in our next generation of the library the page count will begin from 1 . This new library should be available soon, so please stay tuned with our newsletters .

If you will have more questions please feel free to contact us.

--------

Best regards,
Evgen Efimov

http://groupdocs.com
Your Document Collaboration APIs
Follow us on LinkedIn, Twitter, Facebook and Google+


#3

Hello,


I need to convert each page from a .tiff file but I am unable to get the total number of pages.
Below is my code to get total pages of the document:
@Override
public int getPageCount(byte[] inputFileByteArr, String fileName) throws Exception {
long start = System.currentTimeMillis();
int numPages = -1;
ByteArrayInputStream bais = null;
try {
bais = new ByteArrayInputStream(inputFileByteArr);
numPages = CONVERSION_HANDLER.getPageCount(bais, fileName);
} catch (Exception err) {
throw new Exception(“Unable to get number of pages in file”);
} finally {
try {
if (bais != null) {
bais.close();
bais = null;
}
} catch (Exception e) {
logger.error(“Error occurred while closing stream”, e);
}
long finish = System.currentTimeMillis();
logger.info(“Time taken for getting page count (fileName: {}) is {} ms”, fileName, (finish - start));
}
return numPages;
}


#4
Hello,

Yes, we have reproduced the issue on our side , that getPageCount method always reverts 0 for images number. Our product team was notified about the issue and they will fix it in our next generation of the library. We will notify you, when the issue will be fixed.

Sorry for the inconvenience.

--------

Best regards,
Evgen Efimov

http://groupdocs.com
Your Document Collaboration APIs
Follow us on LinkedIn, Twitter, Facebook and Google+