# Printing (on Windows) without using any print dialogs

**URL:** <https://www.ruby-forum.com/t/printing-on-windows-without-using-any-print-dialogs/218960>\
**Category:** wxRuby\
**Created:** [April 17, 2012, 1:33pm UTC](https://www.ruby-forum.com/t/printing-on-windows-without-using-any-print-dialogs/218960 "2012-04-17T13:33:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [April 17, 2012, 1:33pm UTC](https://www.ruby-forum.com/t/printing-on-windows-without-using-any-print-dialogs/218960/1 "2012-04-17T13:33:03Z")

</div>

I am developing a Windows application that is going to print on  
envelopes (C5 and C6 envelopes) based on data, that is retrieved from an  
external order system.

The application is going to be running mostly automatic. So I need to  
bypass the print setup dialog, that is normally used when printing with  
wxRuby.

This presents me with some problems. I create a Wx::PrintData object to  
control the printer, paper size, orientation, etc. like this (the  
printer name is just an example, I hold it in a config file):

pd = Wx::PrintData.new  
pd.set\_printer\_name(“Dell 3110cn”)  
pd.set\_paper\_id(Wx::PAPER\_ENV\_C6)

The last line gives me this error:

`set\_paper\_id’: Expected argument 1 of type wxPaperSize, but got Fixnum  
31 (TypeError)

The type wxPaperSize is not defined (as far as I can see), but it iś  
something coming from the SWIG interface. I don’t really know how to  
solve this.

If outputting the existing paper\_id I get:

> puts pd.get\_paper\_id.inspect

#SWIG::TYPE\_p\_wxPaperSize:0x2173c40

Which doesn’t really make it any clearer for me. So how should I do  
this?

/ Carsten

---

<div class="post-metadata">

**Author:** ![tuktuk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/77aa72/32.png) [@tuktuk](https://www.ruby-forum.com/u/tuktuk)\
**Post date:** [April 19, 2012, 10:35pm UTC](https://www.ruby-forum.com/t/printing-on-windows-without-using-any-print-dialogs/218960/2 "2012-04-19T22:35:49Z")

</div>

Hi Carsten

On 17/04/12 12:33, Carsten G. wrote:

> `set\_paper\_id’: Expected argument 1 of type wxPaperSize, but got Fixnum  
> 31 (TypeError)
> 
> The type wxPaperSize is not defined (as far as I can see), but it iś  
> something coming from the SWIG interface. I don’t really know how to  
> solve this.

It looks like wxRuby doesn’t know at the moment that PaperSize is just a  
constant and it should treat it as such. It’s an oversight in the  
wrapping, sorry.

> #SWIG::TYPE\_p\_wxPaperSize:0x2173c40
> 
> Which doesn’t really make it any clearer for me. So how should I do  
> this?

It’s not something that can be worked round directly in Ruby, I think.  
The best thing to do would be to post a bug - it isn’t a difficult fix  
to the C wrapper, but I don’t have time now I’m afraid.

alex
