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

Free Support Forum - aspose.com

Margins not working for top and bottom

I’m trying to set equal margins in my document for top, bottom, left and right.
When I’m applying margin by creating blank document at that its working fine. But its not working when I’m trying to apply these settings in existing document.

Following is the code snippet I’m using to apply the settings.

public class ConvertBetweenMeasurementUnits {
	public static void main(String[] args) throws Exception {
		// Open the document.
		Document doc = new Document("/home/user/Downloads/existing.docx");
		DocumentBuilder builder = new DocumentBuilder(doc);
		PageSetup pageSetup = builder.getPageSetup();

Please find attached related files.zip (26.1 KB)
for your reference and let me know if you have any solution for this issue.


Unfortunately, we were unable to detect the issue on our side. As I can see, the margins in your output document are set to the desired values (0.984 inches from each side).
Could you please share a screenshot, that shows the unexpected behavior? We will investigate the issue and provide you information on it.

Thanks @sergey.lobanov for the quick response.

Yes, I’ve check the same. I was checking in LibreOffice (Ubuntu), where its showing incorrect but In Windows, its good as expected.