I create an OpenOffice document with Delphi.
My question is : How to set TopMargin, BottomMargin, LeftMargin, RightMargin of the document?
Thanks for help
[Solved] Writer How to set Margins of a document?
[Solved] Writer How to set Margins of a document?
Last edited by jfpetit on Tue Dec 11, 2012 3:28 pm, edited 1 time in total.
OpenOffice 3.4.1
Windows XP
Windows XP
Re: Writer How to set Margins of a document?
Best way is to /Format /Styles and Formatting, click on 4th icon from left, then right click on Page Style you wish to change and select Modify. On Page tab you can now set your Paper size and Margins. Note that, in spite of settings on Organiser tab, page styles are not hierarchical (i.e., are not interlinked so one depends on another).
| Edit: Reading your query again, I see that you wish to set the style from Delphi. You may need to inspect a file with some low level utility such as MRI or Xray Xray to find the parameters you need to set. |
Apache OpenOffice 4.1.16 on Xubuntu 24.04.4 LTS
Re: Writer How to set Margins of a document?
Thanks but i want to do that by programming in Delphi.
OpenOffice 3.4.1
Windows XP
Windows XP
Re: Writer How to set Margins of a document?
Thanks
But I don't find anything to set margins of document in the URL you give.
But I don't find anything to set margins of document in the URL you give.
OpenOffice 3.4.1
Windows XP
Windows XP
Re: Writer How to set Margins of a document?
I found this in http://www.pitonyak.org/AndrewMacro.odt
Listing 5.32: Set the margins by modifying the text style.
Thanks to JohnSUN-Pensioner
Listing 5.32: Set the margins by modifying the text style.
Code: Select all
Sub Margins( )
Dim oStyleFamilies, oFamilies, oPageStyles, oStyle
Dim oVCurs, oPageStyleName
Dim fromleft%, fromtop%, fromright%, frombottom%
Dim oDoc
oDoc = ThisComponent
REM You don't need the view cursor, you can use any TextCursor
oVCurs = oDoc.CurrentController.getViewCursor()
oPageStyleName = oVCurs.PageStyleName
oPageStyles = oDoc.StyleFamilies.getByName("PageStyles")
oStyle = oPageStyles.getByName(oPageStyleName)
REM fromleft, fromtop, fromright, frombottom = whatever you want
oStyle.LeftMargin = fromleft
oStyle.TopMargin = fromtop
oStyle.RightMargin = fromright
oStyle.BottomMargin = frombottom
End SubOpenOffice 3.4.1
Windows XP
Windows XP