Free Support Forum - aspose.com

Know the margins of each page of a Word document (.doc) [Java]?

I need to know if it´s possible to know the margins of each page of a Word document (.doc). I´m using Aspose Words API in Java.

Thank you in advance,
David

Hi

Thanks for your inquiry. Yes of course you can get page margins. You can use PageSetup to achieve this. See the following link for more information.

http://www.aspose.com/documentation/file-format-components/aspose.words-for-.net-and-java/com/aspose/words/pagesetup.html#LeftMargin

Hope this helps.

Best regards.

I have a Word document with different margins in each page.

With Aspose Words API for Java, I have the possibility to know the margins of each section, but I can´t get the margin of each page. Is that true?

Thank you in advance,
David

Hi

Thanks for your inquiry. Pages do not have different margins in the Word document. If each page in your document has different margins then each page is represented as separate section. So if you need to get margins of pages then you need to get margins of each section.

Best regards.

Hi,


For Aspose.Words - Java

1. How it is possible to GET MARGINS via Aspose.Words.
Also how it is possible to Read/Get DocumentBuilder ? from existing file I have found only how it is possible to create:
http://www.aspose.com/documentation/java-components/aspose.words-for-java/com/aspose/words/pagesetup.html

Thank you.

Hi again,

Seems like I have found how to get Margins, from sections, but....
double leftMargin = doc.getFirstSection().getPageSetup().getLeftMargin();
But I have recived: 85.05, In word I have settings: 3 cm.
It is possible to get values in cm dimension in Aspose?
Or How I can convert this value to 3 cm ? thank you.

Hi
Alexander,


Thanks for your inquiry. Please note that Document.FirstSection.PageSetup.LeftMargin returns or sets the distance (in double points) between the left edge of the page and the left boundary of the body text. You can easily convert this double value to other units e.g:

double
inPoints = doc.FirstSection.PageSetup.LeftMargin;
double
inInches = ConvertUtil.PointToInch(inPoints);
// As 1 inch = 2.54 centimeters
double
inCentimeters = inInches * 2.54;

I hope, this will help.

Best Regards,
awais.hafeez:
Hi Alexander,

Thanks for your inquiry. Please note that Document.FirstSection.PageSetup.LeftMargin returns or sets the distance (in double points) between the left edge of the page and the left boundary of the body text. You can easily convert this double value to other units e.g:

double inPoints = doc.FirstSection.PageSetup.LeftMargin;
double inInches = ConvertUtil.PointToInch(inPoints);
// As 1 inch = 2.54 centimeters
double inCentimeters = inInches * 2.54;

I hope, this will help.

Best Regards,

Hi, Thank you.

Yes it works.

// As 1 inch = 2.54 centimeters
double inCentimeters = inInches * 2.54;

But I also was need to make the following ( ROUND ), continue your code:

double result = inCentimeters * 100;
result = Math.round( result );
result = result / 100;
return result;

now result: 3.0
and not 3.000375

/**
* 1 inch = 2,54 cm leftMargin
* for example = 85.05 then inches will be 1.18125
* then cm = 1.18125 * 2.54 (cm) =
* 3.000375 then we round up it to 3.0

*
P.S. So it works, here is no questions.

Hi
Alexander,


Thanks for your feedback. It is perfect that you managed to resolve the problem on your side. If we can help you with anything else, please feel free to ask.

Best Regards,

The issues you have found earlier (filed as WORDSNET-2978) have been fixed in this .NET update and this Java update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.
(18)