Hello,
I found a great solution to mimick my stationary, and it is to put the image of my stationary as a full-page background in my letter-template. So if I send someone a PDF of my letter through email, he gets the letter with my heading etc.
Now I've found an option in Print > Printer options > Elements to unselect the 'background'-element, which is a perfect solution, except for the fact that this setting is forgotten by openoffice / my printer everytime I make a new document out of this template.
Instead of teaching my 2 colleagues to always deselect this option, I'm looking for a macro to automate the deselection of this option upon loading the document.
Studying the openoffice-API is a disaster though. I find several Xprintable, print, getprinter, setprinter, printoptions etc.-possible attributes, but none of them seems to be able to set the attribute 'do not print background'.
Does anyone know the solution?
THX!
[Solved] Not printing the background
[Solved] Not printing the background
Last edited by zenlord on Tue Jan 12, 2010 11:03 am, edited 1 time in total.
LibreOffice 4.1 on Linux (Debian Wheezy backports)
Re: Not printing the background
I found the answer here. The service that supports the printPageBackground property is com.sun.star.view.PrintSettings, but I couldn't find how to access it. The post I referenced shows the way.
Code: Select all
oDoc = ThisComponent
oDocSettings = oDoc.createInstance("com.sun.star.text.DocumentSettings")
oDocSettings.PrintPageBackground = False
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
Re: Not printing the background
Thx!
I have been trying different macro's in the last week, but I don't seem to get it working. Stuff I'll try out tonight are:
Maybe someone can rule out one or several of these possibilities.
Something that made me doubt earlier today is the way this macro works: I've been 'testing' the macro by looking at the 'print options'-dialog to see if the option was effectively disabled or not. This was never the case, but maybe the macro doesn't disable this option permanently, but only for a short while (f.e. until the end of the macro?). That would explain why I never saw a disabled print option for the background, and that's why I'll be trying the above macro's with the 'print()'-cmd, effectively printing the document before the macro has finished.
If someone else could shed some (more) light at my problem, I'd be much obliged. Wrestling through the API documentation, the Pitonyak-PDF and the starbasic developer tutorial has not really enlightened me (although I know my way around PHP, so I'm not a complete beginner when it comes to coding/hacking/'programming').
Thx again!
I have been trying different macro's in the last week, but I don't seem to get it working. Stuff I'll try out tonight are:
Code: Select all
Dim oText As Object
oDoc = ThisComponent
oText = oDoc.DocumentSettings
oText.PrintPageBackground = False
print(oDoc)
oDoc = ThisComponent
Dim oDocSettings As Object
oDocSettings = createInstance("com.sun.star.text.DocumentSettings")
oDocSettings.PrintPageBackground = False
print(oDoc)
oDoc = ThisComponent
Dim oDocSettings As Object
oDocSettings = createInstance("com.sun.star.view.PrintSettings")
oDocSettings.PrintPageBackground = False
print(oDoc)
Something that made me doubt earlier today is the way this macro works: I've been 'testing' the macro by looking at the 'print options'-dialog to see if the option was effectively disabled or not. This was never the case, but maybe the macro doesn't disable this option permanently, but only for a short while (f.e. until the end of the macro?). That would explain why I never saw a disabled print option for the background, and that's why I'll be trying the above macro's with the 'print()'-cmd, effectively printing the document before the macro has finished.
If someone else could shed some (more) light at my problem, I'd be much obliged. Wrestling through the API documentation, the Pitonyak-PDF and the starbasic developer tutorial has not really enlightened me (although I know my way around PHP, so I'm not a complete beginner when it comes to coding/hacking/'programming').
Thx again!
LibreOffice 4.1 on Linux (Debian Wheezy backports)
Re: Not printing the background
OK, I think I nailed it and want to leave this code snippet here for anyone who wants it:
The code worked last night, but I'll be getting my new printer with different trays somewhere this week. I found http://www.oooforum.org/forum/viewtopic ... rpapertray, which suggests that my tray-selection is not correct.
Also beware: I'm typing this from memory - I'll check the code tonight at home.
Zl.
Code: Select all
oDoc = ThisComponent
DIM oDocSettings AS Object
oDocSettings = createInstance("com.sun.star.view.PrintSettings")
oDocSettings.PrintPageBackground = False
DIM oPropertyValue(3) AS new com.sun.star.beans.PropertyValue
oPropertyValue(0).Name = "Copies"
oPropertyValue(0).Value = "1"
oPropertyValue(1).Name = "Collate"
oPropertyValue(1).Value = True
oPropertyValue(2).Name = "PrinterPaperTray"
oPropertyValue(2).Value = "Tray1"
oDoc.Print(oPropertyValue())
Also beware: I'm typing this from memory - I'll check the code tonight at home.
Zl.
LibreOffice 4.1 on Linux (Debian Wheezy backports)
Re: [Solved] Not printing the background
EDIT: I posted a macro to solve a complete question, but since this macro didn't do exactly what I needed, I'm just posting the answer to the initial question and I will open a new thread for the other problems(s).
So: This piece of macro works to disable printing of the background:
So: This piece of macro works to disable printing of the background:
Code: Select all
Sub printDocWithoutBackground
DIM oPropertyValue(0) AS New com.sun.star.beans.PropertyValue
DIM oDoc
DIM oSettings
oDoc = ThisComponent
REM Set backgroundImage-option to False
oSettings = oDoc.createInstance("com.sun.star.text.DocumentSettings")
oSettings.PrintPageBackground = False
REM Set some print options
oPropertyValue(0).Name = "CopyCount"
oPropertyValue(0).Value = 1
oDoc.Print(oPropertyValue())
End Sub
LibreOffice 4.1 on Linux (Debian Wheezy backports)