We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Page count return wrong output in AWS instance

when I am tested in the local server it’s working filne. But in AWS It’s return wrong output.

Document document = new Document(filePath);
// for test
TxtSaveOptions options = new TxtSaveOptions();
options.setSaveFormat(com.aspose.words.SaveFormat.TEXT);
options.setEncoding(java.nio.charset.Charset.forName("UTF-8"));
options.setExportHeadersFooters(false);
options.setParagraphBreak("\n");
options.setPreserveTableLayout(false);
options.setPrettyFormat(true);
document.save(name, options);
//document.save(name);
// file data return as a string
File outputFile = new File(name);
String base64 = null;
if (outputFile != null)
{
	FileInputStream fis = null;
	fis = new FileInputStream(outputFile);
	byte[] bytes = new byte[(int)outputFile.length()];
	fis.read(bytes);
	base64 = new sun.misc.BASE64Encoder().encode(bytes);
	fis.close();
}

//byte[] base64 = Base64.encodeBase64(document.getText().getBytes());
documentData.setFileData(new String(base64));
// find page count
documentData.setTotalNumberOfPages(document.getPageCount()); 

@rabin.samanta,

What are the page count values you are getting on local server and on AWS?

Please also ZIP and upload your sample input document (you are getting this problem with) here for testing. We will then investigate the issue on our end and provide you more information.

@awais.hafeez
test.zip (9.6 KB)
Local pageCount = 2
AWS pageCount =1

@rabin.samanta,

After an initial test with the licensed latest version of Aspose.Words for Java i.e. 19.2, we were unable to reproduce this issue on our end. We would suggest you please upgrade to the latest version of Aspose.Words for Java on both the local and AWS servers. Hope, this helps.