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

Free Support Forum - aspose.com

Aspose.Words returns different values for Header/Footer distance at Windows 10 and Windows Server 2016

Hi,

We are currently using Aspose.Words java version 19.3 to generate word files. We observed a difference in the header/footer distance in the generated word file when the same aspose code is executed in different environments. I have collected the properties which describe how different the environments(OS,locale etc) are using the sample code below. We are using the same JRE version though. For viewing the word file we use Microsoft 365 for enterprise.

Sample code -
public class Test {

public static void main(String[] args) throws Exception {
	String outputPath = "";
	if(args != null && args.length > 0) {
		outputPath = args[0];
	}
	TestUtils.setupLicense();
	TestUtils.printSystemProperties();
	TestUtils.printJREDetails();
	TestUtils.printAsposeVersion();
	Document doc = new Document();
	DocumentBuilder docBuilder = new DocumentBuilder(doc);
	docBuilder.writeln("Aspose header/footer distance test");
	double ptn2cmsRate = 0.0352778;
	double headerDistance = ptn2cmsRate * docBuilder.getPageSetup().getHeaderDistance();
	double footerDistance = ptn2cmsRate * docBuilder.getPageSetup().getFooterDistance();
	System.out.println("****************************************************");
	System.out.println("Header distance found : " + headerDistance+" cms");
	System.out.println("Footer distance found : " + footerDistance+" cms");
	doc.save(outputPath+"outputD.doc");
	doc.save(outputPath+"outputDX.docx");
	System.out.println("Document generated successfully!!");
	System.out.println("****************************************************");
}

}

Sample code output:

<-Machine 1 Details->

user.country=IN
os.name=Windows 10
user.timezone=Asia/Calcutta

java.version: 1.8.0_191
java.vendor: IBM Corporation
java.vm.version: 2.9
java.vm.vendor: IBM Corporation
java.vm.info: JRE 1.8.0 Windows 10 amd64-64-Bit Compressed References 20181029_400846 (JIT enabled, AOT enabled)
OpenJ9 - c5c78da
OMR - 3d5ac33
IBM - 8c1bdc2

Aspose product and version is: Aspose.Words for Java : 19.3


Header distance found : 1.24883412 cms
Footer distance found : 1.24883412 cms
Document generated successfully!!


<-Machine 2 Details->
user.country=US
os.name=Windows Server 2016
user.timezone=Europe/Athens

java.version: 1.8.0_191
java.vendor: IBM Corporation
java.vm.version: 2.9
java.vm.vendor: IBM Corporation
java.vm.info: JRE 1.8.0 Windows Server 2016 amd64-64-Bit Compressed References 20181029_400846 (JIT enabled, AOT enabled)
OpenJ9 - c5c78da
OMR - 3d5ac33
IBM - 8c1bdc2

Aspose product and version is: Aspose.Words for Java : 19.3


Header distance found : 1.2700008 cms
Footer distance found : 1.2700008 cms
Document generated successfully!!


Thanks.

@Akash007

We suggest you please try the latest version of Aspose.Words for Java 20.5 and let us know how it goes on your side. Hope this helps you.

@tahir.manzoor
I ran the same code with aspose-words-20.5-jdk17.jar . I got the same results back.
For windows 10, the header/footer distance is 1.25 cms(approx) whereas for Windows server 2016 it’s 1.27cms(approx)

@Akash007

We are investigating this issue and will get back to you soon.

@tahir.manzoor
Thanks.

@Akash007

We have tested the scenario and have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-20532 . You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

@tahir.manzoor
Thanks for the update.

@Akash007

It is to inform you that the issue which you are facing is actually not a bug in Aspose.Words. So, we have closed this issue (WORDSNET-20532) as ‘Not a Bug’.

Please note that Aspose.Wrods mimics the behavior of MS Word. MS Word defaults for header/footer distance from the top/bottom edge of the page depends on system local during the generation of the Normal template.

For en-US (1033) culture, it is 720 twips (1.2700008 cms)
For Hindi culture, it is 708 twips (1.24883412 cms)

So, this is just MS Word behavior. This distance depends on the current culture, so, if you want the same distance on different machines, please set the desired culture explicitly.

For example:
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-nz", false);