Difference between revisions of "Printing a document"

From Apache OpenOffice Wiki
Jump to: navigation, search
m
 
Line 1: Line 1:
 
'''To print the current document without passing any arguments: '''
 
'''To print the current document without passing any arguments: '''
  
<source lang="oobas">
+
<syntaxhighlight lang="oobas">
 
thisComponent.print(array())
 
thisComponent.print(array())
</source>
+
</syntaxhighlight>
 
A more generic print routine:  
 
A more generic print routine:  
  
<source lang="oobas">
+
<syntaxhighlight lang="oobas">
 
sub subPrint(oDoc, optional ncopies, optional bCollate, optional sPages, optional sFileName)
 
sub subPrint(oDoc, optional ncopies, optional bCollate, optional sPages, optional sFileName)
 
dim mPrintOptions()
 
dim mPrintOptions()
Line 24: Line 24:
 
oDoc.print(mPrintOptions())
 
oDoc.print(mPrintOptions())
 
end sub
 
end sub
</source>
+
</syntaxhighlight>
 
This function calls subAddProperty which is defined in [[working with properties]].  
 
This function calls subAddProperty which is defined in [[working with properties]].  
  
 
Example of calling this function:  
 
Example of calling this function:  
  
<source lang="oobas">
+
<syntaxhighlight lang="oobas">
 
subprint(ThisComponent, 1, ,"1", "PrintExample.txt")
 
subprint(ThisComponent, 1, ,"1", "PrintExample.txt")
</source>
+
</syntaxhighlight>
  
 
[[Category:Basic:Tutorials]]
 
[[Category:Basic:Tutorials]]

Latest revision as of 14:45, 24 August 2022

To print the current document without passing any arguments:

thisComponent.print(array())

A more generic print routine:

sub subPrint(oDoc, optional ncopies, optional bCollate, optional sPages, optional sFileName)
dim mPrintOptions()
 
if not isMissing(nCopies) then
        subAddproperty(mPrintOptions(), "CopyCount", nCopies)
end if
if not isMissing(bCollate) then
        subAddproperty(mPrintOptions(), "Collate", bCollate)
end if
if not isMissing(sPages) then
        subAddproperty(mPrintOptions(), "Pages", sPages)
end if
if not isMissing(sFilename) then
        subAddproperty(mPrintOptions(), "FileName", sFileName)
end if
oDoc.print(mPrintOptions())
end sub

This function calls subAddProperty which is defined in working with properties.

Example of calling this function:

subprint(ThisComponent, 1, ,"1", "PrintExample.txt")
Personal tools