Difference between revisions of "Documentation/DevGuide/Drawings/Printing Drawing Documents"
OOoWikiBot (Talk | contribs) m (Robot: Changing Category:Drawing Documents and Presentation Documents) |
|||
(2 intermediate revisions by 2 users not shown) | |||
Line 5: | Line 5: | ||
|NextPage=Documentation/DevGuide/Drawings/Working with Drawing Documents | |NextPage=Documentation/DevGuide/Drawings/Working with Drawing Documents | ||
}} | }} | ||
− | {{DISPLAYTITLE:Printing Drawing Documents}} | + | {{Documentation/DevGuideLanguages|Documentation/DevGuide/Drawings/{{SUBPAGENAME}}}} |
+ | {{DISPLAYTITLE:Printing Drawing Documents}} | ||
=== Printer and Print Job Settings === | === Printer and Print Job Settings === | ||
<!--<idltopic>com.sun.star.view.XPrintable;com.sun.star.view.PrinterDescriptor;com.sun.star.view.PrintOptions</idltopic>--> | <!--<idltopic>com.sun.star.view.XPrintable;com.sun.star.view.PrinterDescriptor;com.sun.star.view.PrintOptions</idltopic>--> | ||
Printing is a common office functionality. Refer to Chapter [[Documentation/DevGuide/OfficeDev/Office Development|Office Development]] for additional information. The Draw document implements the <idl>com.sun.star.view.XPrintable</idl> interface for printing. It consists of three methods: | Printing is a common office functionality. Refer to Chapter [[Documentation/DevGuide/OfficeDev/Office Development|Office Development]] for additional information. The Draw document implements the <idl>com.sun.star.view.XPrintable</idl> interface for printing. It consists of three methods: | ||
− | + | <syntaxhighlight lang="java"> | |
sequence< com::sun::star::beans::PropertyValue > getPrinter() | sequence< com::sun::star::beans::PropertyValue > getPrinter() | ||
void setPrinter( | void setPrinter( | ||
[in] sequence< com::sun::star::beans::PropertyValue > aPrinter) | [in] sequence< com::sun::star::beans::PropertyValue > aPrinter) | ||
void print( | void print( | ||
− | [in] sequence< com::sun::star::beans::PropertyValue > xOptions) | + | [in] sequence< com::sun::star::beans::PropertyValue > xOptions)</syntaxhighlight> |
To print to the standard printer without settings, use the snippet below with a given document <code>xDoc</code>: | To print to the standard printer without settings, use the snippet below with a given document <code>xDoc</code>: | ||
− | + | <syntaxhighlight lang="java"> | |
// query the XPrintable interface from your document | // query the XPrintable interface from your document | ||
XPrintable xPrintable = (XPrintable)UnoRuntime.queryInterface(XPrintable.class, xDoc); | XPrintable xPrintable = (XPrintable)UnoRuntime.queryInterface(XPrintable.class, xDoc); | ||
Line 26: | Line 27: | ||
// kick off printing | // kick off printing | ||
− | xPrintable.print(printOpts); | + | xPrintable.print(printOpts);</syntaxhighlight> |
There are two groups of properties involved in general printing. The first one is used with <code>setPrinter()</code> and <code>getPrinter()</code>, and controls the printer, the second one is passed to <code>print()</code> and controls the print job. | There are two groups of properties involved in general printing. The first one is used with <code>setPrinter()</code> and <code>getPrinter()</code>, and controls the printer, the second one is passed to <code>print()</code> and controls the print job. | ||
Line 79: | Line 80: | ||
|<idlm>com.sun.star.view.PrintOptions:Pages</idlm> | |<idlm>com.sun.star.view.PrintOptions:Pages</idlm> | ||
|<code>string</code> - Specifies the pages to print. It has the same format as in the print dialog of the GUI, for example, 1, 3, 4-7, 9. | |<code>string</code> - Specifies the pages to print. It has the same format as in the print dialog of the GUI, for example, 1, 3, 4-7, 9. | ||
+ | |- | ||
+ | |<idlm>com.sun.star.view.PrintOptions:Wait</idlm> | ||
+ | |<code>boolean</code> - Advises that the print job should be performed synchronously, i.e. wait until printing is complete before returning from printing. Otherwise return is immediate and following actions (e.g. closing the corresponding model) may fail until printing is complete. Default is false. | ||
|} | |} | ||
Line 84: | Line 88: | ||
The following method uses both, <code>PrinterDescriptor</code> and <code>PrintOptions</code>, to print to a specific printer and preselect the pages to print: | The following method uses both, <code>PrinterDescriptor</code> and <code>PrintOptions</code>, to print to a specific printer and preselect the pages to print: | ||
− | + | <syntaxhighlight lang="java"> | |
protected void printDocComponent(XComponent xDoc) throws java.lang.Exception { | protected void printDocComponent(XComponent xDoc) throws java.lang.Exception { | ||
XPrintable xPrintable = (XPrintable)UnoRuntime.queryInterface(XPrintable.class, xDoc); | XPrintable xPrintable = (XPrintable)UnoRuntime.queryInterface(XPrintable.class, xDoc); | ||
Line 100: | Line 104: | ||
xPrintable.print(printOpts); | xPrintable.print(printOpts); | ||
− | } | + | }</syntaxhighlight> |
In Draw documents, one slide is printed as one page on the printer by default. In the example above, slide one through four and slide seven are printed. | In Draw documents, one slide is printed as one page on the printer by default. In the example above, slide one through four and slide seven are printed. |
Latest revision as of 14:14, 20 December 2020
- Printing Drawing Documents
Printer and Print Job Settings
Printing is a common office functionality. Refer to Chapter Office Development for additional information. The Draw document implements the com.sun.star.view.XPrintable interface for printing. It consists of three methods:
sequence< com::sun::star::beans::PropertyValue > getPrinter() void setPrinter( [in] sequence< com::sun::star::beans::PropertyValue > aPrinter) void print( [in] sequence< com::sun::star::beans::PropertyValue > xOptions)
To print to the standard printer without settings, use the snippet below with a given document xDoc
:
// query the XPrintable interface from your document XPrintable xPrintable = (XPrintable)UnoRuntime.queryInterface(XPrintable.class, xDoc); // create an empty printOptions array PropertyValue[] printOpts = new PropertyValue[0]; // kick off printing xPrintable.print(printOpts);
There are two groups of properties involved in general printing. The first one is used with setPrinter()
and getPrinter()
, and controls the printer, the second one is passed to print()
and controls the print job.
The method getPrinter()
returns a sequence of PropertyValue
structs describing the printer containing the properties specified in the service com.sun.star.view.PrinterDescriptor. It comprises the following properties:
Properties of com.sun.star.view.PrinterDescriptor | |
---|---|
Name | string - Specifies the name of the printer queue to be used.
|
PaperOrientation | com.sun.star.view.PaperOrientation. Specifies the orientation of the paper. |
PaperFormat | com.sun.star.view.PaperFormat. Specifies a predefined paper size or if the paper size is a user-defined size. |
PaperSize | com.sun.star.awt.Size. Specifies the size of the paper in 1/100 mm. |
IsBusy | boolean - Indicates if the printer is busy.
|
CanSetPaperOrientation | boolean - Indicates if the printer allows changes to PaperOrientation.
|
CanSetPaperFormat | boolean - Indicates if the printer allows changes to PaperFormat.
|
CanSetPaperSize | boolean - Indicates if the printer allows changes to PaperSize.
|
The PrintOptions
offer the following choices for a print job:
Properties of com.sun.star.view.PrintOptions | |
---|---|
CopyCount | short - Specifies the number of copies to print.
|
FileName | string - If set, specifies the name of a file to print to.
|
Collate | boolean - Advises the printer to collate the pages of the copies. If true, a whole document is printed prior to the next copy, otherwise copies for each page are completed together.
|
Pages | string - Specifies the pages to print. It has the same format as in the print dialog of the GUI, for example, 1, 3, 4-7, 9.
|
Wait | boolean - Advises that the print job should be performed synchronously, i.e. wait until printing is complete before returning from printing. Otherwise return is immediate and following actions (e.g. closing the corresponding model) may fail until printing is complete. Default is false.
|
The following method uses PrinterDescriptor
and PrintOptions
to print to a specific printer, and preselect the pages to print:
The following method uses both, PrinterDescriptor
and PrintOptions
, to print to a specific printer and preselect the pages to print:
protected void printDocComponent(XComponent xDoc) throws java.lang.Exception { XPrintable xPrintable = (XPrintable)UnoRuntime.queryInterface(XPrintable.class, xDoc); PropertyValue[] printerDesc = new PropertyValue[1]; printerDesc[0] = new PropertyValue(); printerDesc[0].Name = "Name"; printerDesc[0].Value = "5D PDF Creator"; xPrintable.setPrinter(printerDesc); PropertyValue[] printOpts = new PropertyValue[1]; printOpts[0] = new PropertyValue(); printOpts[0].Name = "Pages"; printOpts[0].Value = "1-4,7"; xPrintable.print(printOpts); }
In Draw documents, one slide is printed as one page on the printer by default. In the example above, slide one through four and slide seven are printed.
Special Print Settings
The printed drawing view (drawings, notes, handout pages, outline), the print quality (color, grayscale), the page options (tile, fit to page, brochure, paper tray) and additional options (page name, date, time, hidden pages) can all be controlled. Settings describes how these settings are used.
Content on this page is licensed under the Public Documentation License (PDL). |