Page 1 of 1
[Solved] Writer How to set Margins of a document?
Posted: Mon Dec 10, 2012 11:17 am
by jfpetit
I create an OpenOffice document with Delphi.
My question is : How to set TopMargin, BottomMargin, LeftMargin, RightMargin of the document?
Thanks for help
Re: Writer How to set Margins of a document?
Posted: Mon Dec 10, 2012 11:24 am
by RoryOF
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. |
Re: Writer How to set Margins of a document?
Posted: Mon Dec 10, 2012 11:36 am
by jfpetit
Thanks but i want to do that by programming in Delphi.
Re: Writer How to set Margins of a document?
Posted: Mon Dec 10, 2012 11:46 am
by jfpetit
Thanks
But I don't find anything to set margins of document in the URL you give.
Re: Writer How to set Margins of a document?
Posted: Tue Dec 11, 2012 3:27 pm
by jfpetit
I found this in
http://www.pitonyak.org/AndrewMacro.odt
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 Sub
Thanks to JohnSUN-Pensioner