Add properties to document like: author, title

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
giciorek
Posts: 4
Joined: Sat Mar 05, 2011 3:42 pm

Add properties to document like: author, title

Post by giciorek »

Hi,

I generate on the fly documents with the OpenOffice API.
Now I want to add some properties to my doc files as author, title ...

As well this properties should be visible in a PDF that I generated from my doc files with the OpenOffice API.

Any Ideas?

Regards,

giciorek
OpenOffice 3.3 on x64
andyroberts1234
Posts: 75
Joined: Fri Feb 11, 2011 2:29 pm

Re: Add properties to document like: author, title

Post by andyroberts1234 »

Quick search of the API on google found this...never used it before but should lead you to the right way http://api.openoffice.org/docs/common/r ... rties.html
Andy

OOO 3.3.0 / Windows 7 64-bit
giciorek
Posts: 4
Joined: Sat Mar 05, 2011 3:42 pm

Re: Add properties to document like: author, title

Post by giciorek »

Ok thanks.

But how to access this properties when I only have the XComponent object?
Can't find any samples.
OpenOffice 3.3 on x64
User avatar
RoryOF
Moderator
Posts: 35210
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Add properties to document like: author, title

Post by RoryOF »

Why not enter the Author details into your Default template?
Apache OpenOffice 4.1.16 on Xubuntu 24.04.4 LTS
JohnV
Volunteer
Posts: 1585
Joined: Mon Oct 08, 2007 1:32 am
Location: Kentucky, USA

Re: Add properties to document like: author, title

Post by JohnV »

In Basic.

Code: Select all

Sub DocInfo
oDoc = ThisComponent
oVC = oDoc.CurrentController.getViewCursor
Info = oDoc.getDocumentInfo
'Other info is available at .getDocumentProperties
oVC.String = Info.Title
oVC.collapseToEnd
oDoc.Text.insertControlCharacter(oVC,0,false)'Paragraph break.
oVC.String = Info.Author
oVC.collapseToEnd 
End Sub
Post Reply