You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openoffice.apache.org by fabian <fm...@netempire.de> on 2012/05/18 12:22:15 UTC
[EXT] Printing without empty pages
Hi,
I am facing the problem that a MailMerge adds empty pages to a document. I know to avoid those pages the user can select to don't print empty pages in the printer settings.
I would like to automatically don't print those pages and tried to start the printer dialog myself with:
PropertyValue[] propertyValueArray = new PropertyValue[1];
propertyValueArray[0] = new PropertyValue();
propertyValueArray[0].Name = "PrintEmptyPages";
propertyValueArray[0].Value = new Boolean(false);
executeDispatch(xDispatchProvider, ".uno:Print", "", 0, propertyValueArray);
Unfortunatly this has no influence on the settings in the print dialog. I have also tried to save and load the document with the property:
property.Name = "IsSkipEmptyPages";
property.Value = new Boolean(true);
but I guess this works only in case one exports a pdf.
Has anybody a solution in which the user does't have to care about empty pages himself?
best,
Fabian
Re: [EXT] Printing without empty pages
Posted by fabian <fm...@netempire.de>.
Hi Ariel,
thanks big time!
I was able to get it to work with java. If you got this only from the API then I should try to become friends with it again ;-)
best,
Fabian
On May 24, 2012, at 4:54 PM, Ariel Constenla-Haile wrote:
> Sub Main
> Dim oDoc as Object
> oDoc = ThisComponent
>
> Dim oDispatchProvider as Object
> Dim oDispatchHelper as Object
> oDispatchProvider = oDoc.getCurrentController().getFrame()
> oDispatchHelper = CreateUnoService("com.sun.star.frame.DispatchHelper")
>
> '===================================================================
> ' Document Settings
>
> 'com.sun.star.text.DocumentSettings
> 'com.sun.star.text.PrintSettings
> 'com.sun.star.text.PrintPreviewSettings
>
> Dim oDocumentSettings as Object
> oDocumentSettings = oDoc.createInstance("com.sun.star.document.Settings")
> oDocumentSettings.setPropertyValue("PrintEmptyPages", False)
>
> oDispatchHelper.executeDispatch(oDispatchProvider,".uno:Print","_self",0,oArguments)
> End Sub
Re: [EXT] Printing without empty pages
Posted by Ariel Constenla-Haile <ar...@apache.org>.
Hi Fernand,
On Thu, May 24, 2012 at 05:40:42PM +0200, Fernand Vanrie wrote:
> Ariel ,
>
> Thanks very instructive (as always) but can you tell me why this
>
> "com.sun.star.document.Settings"
>
> are not available as a property off the document ?
I guess it was a design choice. This how it works in the different
modules, Dev's Guide, section "Overall Document Features" for every
document type:
- service ::com::sun::star::sheet::DocumentSettings
http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/Spreadsheets/Settings
- service ::com::sun::star::text::DocumentSettings
http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/Text/Settings
- service ::com::sun::star::presentation::DocumentSettings
- service ::com::sun::star::drawing::DocumentSettings
http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/Drawings/Settings
I guess we could think of an css::document::XDocumentSettingsSupplier,
using multiple inheritance, it could be implemented in the main
interface of every document type, for Writer, css::text::XTextDocument.
For AOO 4 we should think about using multiple inheritance to easy the
API use in strong typed languages.
Regards
--
Ariel Constenla-Haile
La Plata, Argentina
Re: [EXT] Printing without empty pages
Posted by Fernand Vanrie <so...@pmgroup.be>.
Ariel ,
Thanks very instructive (as always) but can you tell me why this
"com.sun.star.document.Settings"
are not available as a property off the document ?
Greetz
Fernand
> Hi Fabian,
>
> On Fri, May 18, 2012 at 12:22:15PM +0200, fabian wrote:
>> Hi,
>>
>> I am facing the problem that a MailMerge adds empty pages to
>> a document. I know to avoid those pages the user can select to don't
>> print empty pages in the printer settings.
>>
>> I would like to automatically don't print those pages and tried to
>> start the printer dialog myself with:
>>
>> PropertyValue[] propertyValueArray = new PropertyValue[1];
>> propertyValueArray[0] = new PropertyValue();
>> propertyValueArray[0].Name = "PrintEmptyPages";
>> propertyValueArray[0].Value = new Boolean(false);
>>
>> executeDispatch(xDispatchProvider, ".uno:Print", "", 0,
>> propertyValueArray);
> ".uno:Print" only supports the following properties:
>
> * "PrinterName" String
> * "FileName" String
> * "From" Integer
> * "To" Integer
> * "Copies" Integer
> * "RangeText" String
> * "Selection" Boolean
> * "Asynchron" Boolean
> * "Collate" Boolean
> * "Silent" Boolean
>
> Info taken from sfx2/sdi/sfx.sdi: SfxBoolItem Print SID_PRINTDOC
>
> * SfxStringItem PrinterName SID_PRINTER_NAME
> * SfxStringItem FileName SID_FILE_NAME
> * SfxInt16Item From SID_PRINT_FIRST_PAGE
> * SfxInt16Item To SID_PRINT_LAST_PAGE
> * SfxInt16Item Copies SID_PRINT_COPIES
> * SfxStringItem RangeText SID_PRINT_PAGES
> * SfxBoolItem Selection SID_SELECTION
> * SfxBoolItem Asynchron SID_ASYNCHRON
> * SfxBoolItem Collate SID_PRINT_COLLATE
> * SfxBoolItem Silent SID_SILENT
>
>
> In AOO 3.4, setting any argument will send directly to the printer,
> instead of display the print dialog. I don't know if this is a feature
> or a bug.
>
>> Unfortunatly this has no influence on the settings in the print
>> dialog. I have also tried to save and load the document with the
>> property:
>>
>> property.Name = "IsSkipEmptyPages"; property.Value = new
>> Boolean(true);
>>
>> but I guess this works only in case one exports a pdf.
>>
>>
>> Has anybody a solution in which the user does't have to care about
>> empty pages himself?
> "PrintEmptyPages" is a property of service
> com::sun::star::text::PrintSettings
> http://www.openoffice.org/api/docs/common/ref/com/sun/star/text/PrintSettings.html#PrintEmptyPages
>
> This service is included by the service
> com::sun::star::text::DocumentSettings
> http://www.openoffice.org/api/docs/common/ref/com/sun/star/text/DocumentSettings.html
>
> com::sun::star::text::DocumentSettings has to be instanciated at the
> document's factory:
>
>
> Sub Main
> Dim oDoc as Object
> oDoc = ThisComponent
>
> Dim oDispatchProvider as Object
> Dim oDispatchHelper as Object
> oDispatchProvider = oDoc.getCurrentController().getFrame()
> oDispatchHelper = CreateUnoService("com.sun.star.frame.DispatchHelper")
>
> '===================================================================
> ' Document Settings
>
> 'com.sun.star.text.DocumentSettings
> 'com.sun.star.text.PrintSettings
> 'com.sun.star.text.PrintPreviewSettings
>
> Dim oDocumentSettings as Object
> oDocumentSettings = oDoc.createInstance("com.sun.star.document.Settings")
> oDocumentSettings.setPropertyValue("PrintEmptyPages", False)
>
> oDispatchHelper.executeDispatch(oDispatchProvider,".uno:Print","_self",0,oArguments)
> End Sub
>
> In this cases, the API reference is your friend:
> http://www.openoffice.org/api/docs/common/ref/index-files/index-1.html
>
>
> Regards
Re: [EXT] Printing without empty pages
Posted by Ariel Constenla-Haile <ar...@apache.org>.
Hi Fabian,
On Fri, May 18, 2012 at 12:22:15PM +0200, fabian wrote:
> Hi,
>
> I am facing the problem that a MailMerge adds empty pages to
> a document. I know to avoid those pages the user can select to don't
> print empty pages in the printer settings.
>
> I would like to automatically don't print those pages and tried to
> start the printer dialog myself with:
>
> PropertyValue[] propertyValueArray = new PropertyValue[1];
> propertyValueArray[0] = new PropertyValue();
> propertyValueArray[0].Name = "PrintEmptyPages";
> propertyValueArray[0].Value = new Boolean(false);
>
> executeDispatch(xDispatchProvider, ".uno:Print", "", 0,
> propertyValueArray);
".uno:Print" only supports the following properties:
* "PrinterName" String
* "FileName" String
* "From" Integer
* "To" Integer
* "Copies" Integer
* "RangeText" String
* "Selection" Boolean
* "Asynchron" Boolean
* "Collate" Boolean
* "Silent" Boolean
Info taken from sfx2/sdi/sfx.sdi: SfxBoolItem Print SID_PRINTDOC
* SfxStringItem PrinterName SID_PRINTER_NAME
* SfxStringItem FileName SID_FILE_NAME
* SfxInt16Item From SID_PRINT_FIRST_PAGE
* SfxInt16Item To SID_PRINT_LAST_PAGE
* SfxInt16Item Copies SID_PRINT_COPIES
* SfxStringItem RangeText SID_PRINT_PAGES
* SfxBoolItem Selection SID_SELECTION
* SfxBoolItem Asynchron SID_ASYNCHRON
* SfxBoolItem Collate SID_PRINT_COLLATE
* SfxBoolItem Silent SID_SILENT
In AOO 3.4, setting any argument will send directly to the printer,
instead of display the print dialog. I don't know if this is a feature
or a bug.
> Unfortunatly this has no influence on the settings in the print
> dialog. I have also tried to save and load the document with the
> property:
>
> property.Name = "IsSkipEmptyPages"; property.Value = new
> Boolean(true);
>
> but I guess this works only in case one exports a pdf.
>
>
> Has anybody a solution in which the user does't have to care about
> empty pages himself?
"PrintEmptyPages" is a property of service
com::sun::star::text::PrintSettings
http://www.openoffice.org/api/docs/common/ref/com/sun/star/text/PrintSettings.html#PrintEmptyPages
This service is included by the service
com::sun::star::text::DocumentSettings
http://www.openoffice.org/api/docs/common/ref/com/sun/star/text/DocumentSettings.html
com::sun::star::text::DocumentSettings has to be instanciated at the
document's factory:
Sub Main
Dim oDoc as Object
oDoc = ThisComponent
Dim oDispatchProvider as Object
Dim oDispatchHelper as Object
oDispatchProvider = oDoc.getCurrentController().getFrame()
oDispatchHelper = CreateUnoService("com.sun.star.frame.DispatchHelper")
'===================================================================
' Document Settings
'com.sun.star.text.DocumentSettings
'com.sun.star.text.PrintSettings
'com.sun.star.text.PrintPreviewSettings
Dim oDocumentSettings as Object
oDocumentSettings = oDoc.createInstance("com.sun.star.document.Settings")
oDocumentSettings.setPropertyValue("PrintEmptyPages", False)
oDispatchHelper.executeDispatch(oDispatchProvider,".uno:Print","_self",0,oArguments)
End Sub
In this cases, the API reference is your friend:
http://www.openoffice.org/api/docs/common/ref/index-files/index-1.html
Regards
--
Ariel Constenla-Haile
La Plata, Argentina
Re: [EXT] Printing without empty pages
Posted by Fernand Vanrie <so...@pmgroup.be>.
fabian ,
I think you can not have access to the this Print Dialog using the API.
I suppose the best way is to make a "private" print Dialog and using the
API to alter the configuration settings to Not print Empty Pages .
Greetz
Fernand
> Hi Fernand,
>
> Thanks for replying!
> These comments are related to the XPrintable Interface, which will work fine for direct printing I guess. In my case I still want the user to select his printer and printer settings therefore I need the OO print dialog.
>
> best,
> Fabian
Re: [EXT] Printing without empty pages
Posted by Ariel Constenla-Haile <ar...@apache.org>.
Hi Fabian,
On Mon, May 21, 2012 at 11:26:25AM +0200, fabian wrote:
> Hi Fernand,
>
> Thanks for replying! These comments are related to the XPrintable
> Interface, which will work fine for direct printing I guess. In my
> case I still want the user to select his printer and printer settings
> therefore I need the OO print dialog.
You can use XPrintable to set the printer, this will have influence in
printing the document, even if you don't invoke XPrintable.print() but
dispatch .uno:Print
Properties are described in
http://www.openoffice.org/api/docs/common/ref/com/sun/star/view/PrinterDescriptor.html
Read-only properties cannot be set, of course. And there is a settable
property missing in the docs:
"Name"
"PaperOrientation"
"PaperFormat"
"PaperSize"
"PrinterPaperTray" <-- undocumented
Info taken from void SfxPrintHelper::impl_setPrinter() in
sfx2/source/doc/printhelper.cxx
Sub Main
Dim oDoc as Object
oDoc = ThisComponent
Dim oDispatchProvider as Object
Dim oDispatchHelper as Object
oDispatchProvider = oDoc.getCurrentController().getFrame()
oDispatchHelper = CreateUnoService("com.sun.star.frame.DispatchHelper")
'===================================================================
' Printer Settings
Dim aPrintSettings(1) as new com.sun.star.beans.PropertyValue
aPrintSettings(0).Name = "Name"
aPrintSettings(0).Value = "Cups-PDF"
aPrintSettings(1).Name = "PaperOrientation"
aPrintSettings(1).Value = com.sun.star.view.PaperOrientation.LANDSCAPE
oDoc.setPrinter(aPrintSettings)
'===================================================================
'Now notice that the paper orientation is reflected on the dialog!
oDispatchHelper.executeDispatch(oDispatchProvider,".uno:Print","_self",0,Array())
End Sub
Regards
--
Ariel Constenla-Haile
La Plata, Argentina
Re: [EXT] Printing without empty pages
Posted by fabian <fm...@netempire.de>.
Hi Fernand,
Thanks for replying!
These comments are related to the XPrintable Interface, which will work fine for direct printing I guess. In my case I still want the user to select his printer and printer settings therefore I need the OO print dialog.
best,
Fabian
Re: [EXT] Printing without empty pages
Posted by Fernand Vanrie <so...@pmgroup.be>.
fabian ,
matbe this comments on a resolved issue
<https://issues.apache.org/ooo/show_bug.cgi?id=87495> can helps ?
> Hi,
>
> I am facing the problem that a MailMerge adds empty pages to a document. I know to avoid those pages the user can select to don't print empty pages in the printer settings.
>
> I would like to automatically don't print those pages and tried to start the printer dialog myself with:
>
> PropertyValue[] propertyValueArray = new PropertyValue[1];
> propertyValueArray[0] = new PropertyValue();
> propertyValueArray[0].Name = "PrintEmptyPages";
> propertyValueArray[0].Value = new Boolean(false);
>
> executeDispatch(xDispatchProvider, ".uno:Print", "", 0, propertyValueArray);
>
> Unfortunatly this has no influence on the settings in the print dialog. I have also tried to save and load the document with the property:
>
> property.Name = "IsSkipEmptyPages";
> property.Value = new Boolean(true);
>
> but I guess this works only in case one exports a pdf.
>
>
> Has anybody a solution in which the user does't have to care about empty pages himself?
>
> best,
> Fabian
>
>