[Solved] Add line numbers and export to pdf via macro

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
cemsal
Posts: 4
Joined: Tue Feb 01, 2011 6:54 pm

[Solved] Add line numbers and export to pdf via macro

Post by cemsal »

Hi, I need to do what is in subject, calling the macro through php exec() function; in fact I need to do it, in a website, so trasparently for the user; now I'm developing in a Windows Seven environment, then I will have to migrate to Linux.
Using Macros (Basic) I can already export to pdf without any dialog box shown to the user (even if I still have some problem with exec(), I can execute the code in a simple prompt Windows... I guest the problem with php is related to users and privileges... anyway).
The problem is the line numbers. I've tried to record a Macro to have a basic macro to start working on, and I've found this instruction:

dispatcher.executeDispatch(document, ".uno:LineNumberingDialog", "", 0, array())

The problem is that this instruction open a dialog, and I don't want it. I want all the process works trasparently, without asking anything.
I searched a lot, for info on LineNumberingDialog but I didn't found anything really helpful.
Do you have ideas if and how can I get what I want?
Last edited by cemsal on Wed Feb 02, 2011 10:53 am, edited 1 time in total.
OpenOffice 3.3 on Windows Seven
hanya
Volunteer
Posts: 885
Joined: Fri Nov 23, 2007 9:27 am
Location: Japan

Re: Add line numbers and export to pdf via macro

Post by hanya »

In the Basic,

Code: Select all

ThisComponent.getLineNumberingProperties().IsOn = True
Please, edit this thread's initial post and add "[Solved]" to the subject line if your problem has been solved.
Apache OpenOffice 4-dev on Xubuntu 14.04
cemsal
Posts: 4
Joined: Tue Feb 01, 2011 6:54 pm

Re: Add line numbers and export to pdf via macro

Post by cemsal »

Wow, really thank you. Last thing I need, is to modify some options (for example the interval between numbers, the position, etc.). How can I do that? Does exist online a list of the options that I can use via macro for the line numbers?
OpenOffice 3.3 on Windows Seven
hanya
Volunteer
Posts: 885
Joined: Fri Nov 23, 2007 9:27 am
Location: Japan

Re: Add line numbers and export to pdf via macro

Post by hanya »

Please, edit this thread's initial post and add "[Solved]" to the subject line if your problem has been solved.
Apache OpenOffice 4-dev on Xubuntu 14.04
cemsal
Posts: 4
Joined: Tue Feb 01, 2011 6:54 pm

Re: Add line numbers and export to pdf via macro

Post by cemsal »

Many many thanks!
OpenOffice 3.3 on Windows Seven
anj
Posts: 4
Joined: Fri Apr 05, 2013 6:38 am

Re: [Solved] Add line numbers and export to pdf via macro

Post by anj »

Can you share that macro...pls.....
OpenOffice 3.1
cemsal
Posts: 4
Joined: Tue Feb 01, 2011 6:54 pm

Re: [Solved] Add line numbers and export to pdf via macro

Post by cemsal »

Hey, I here is the code (it's a Basic Macro)
REM ***** BASIC *****

sub Main (fileinput, fileoutput)
dim InputUrl as String
InputUrl = convertToUrl(fileinput)

rem MsgBox(InputUrl)

dim OutputUrl as String
OutputUrl = convertToUrl(fileoutput)

rem MsgBox(OutputUrl)

dim document as object
dim dispatcher as object

dim pPropValues(1) as new com.sun.star.beans.PropertyValue
pPropValues(0).Name = "ReadOnly"
pPropValues(0).Value = true
pPropValues(1).Name = "Hidden"
pPropValues(1).Value = true

document = starDeskTop.loadComponentFromUrl(InputUrl, "_blank", 0, pPropValues())
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

document.getLineNumberingProperties().IsOn = True
document.getLineNumberingProperties().Interval = 1

dim args2(2) as new com.sun.star.beans.PropertyValue
args2(0).Name = "URL"
args2(0).Value = OutputUrl
args2(1).Name = "FilterName"
args2(1).Value = "writer_pdf_Export"
args2(2).Name = "FilterData"
args2(2).Value = Array(Array("UseLosslessCompression",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("Quality",0,90,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ReduceImageResolution",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("MaxImageResolution",0,300,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("UseTaggedPDF",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("SelectPdfVersion",0,0,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ExportNotes",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ExportBookmarks",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("OpenBookmarkLevels",0,-1,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("UseTransitionEffects",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("IsSkipEmptyPages",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("IsAddStream",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("EmbedStandardFonts",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("FormsType",0,0,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ExportFormFields",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("AllowDuplicateFieldNames",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("HideViewerToolbar",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("HideViewerMenubar",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("HideViewerWindowControls",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ResizeWindowToInitialPage",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("CenterWindow",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("OpenInFullScreenMode",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("DisplayPDFDocumentTitle",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("InitialView",0,0,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("Magnification",0,0,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("Zoom",0,100,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("PageLayout",0,0,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("FirstPageOnLeft",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("InitialPage",0,1,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("Printing",0,2,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("Changes",0,4,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("EnableCopyingOfContent",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("EnableTextAccessForAccessibilityTools",0,true,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ExportLinksRelativeFsys",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("PDFViewSelection",0,0,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ConvertOOoTargetToPDFTarget",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("ExportBookmarksToPDFDestination",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("_OkButtonString",0,"",com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("EncryptFile",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("DocumentOpenPassword",0,"",com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("RestrictPermissions",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("PermissionPassword",0,"",com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("",0,,com.sun.star.beans.PropertyState.DIRECT_VALUE))

dispatcher.executeDispatch(document.getCurrentController(), ".uno:ExportToPDF", "", 0, args2())

document.setModified(false)
document.close(true)
end sub
I hope it will be helpful for you.
Bye
OpenOffice 3.3 on Windows Seven
anj
Posts: 4
Joined: Fri Apr 05, 2013 6:38 am

Re: [Solved] Add line numbers and export to pdf via macro

Post by anj »

Thank u... :D
OpenOffice 3.1
Post Reply