# Printoperation dunno howto

**URL:** <https://www.ruby-forum.com/t/printoperation-dunno-howto/76674>\
**Category:** Ruby-Gnome 2\
**Created:** [November 20, 2006, 2:47pm UTC](https://www.ruby-forum.com/t/printoperation-dunno-howto/76674 "2006-11-20T14:47:07Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [November 20, 2006, 2:47pm UTC](https://www.ruby-forum.com/t/printoperation-dunno-howto/76674/1 "2006-11-20T14:47:07Z")

</div>

hi,

i managed to print some pages, header, footer positioned, i liked it,  
almost felt it done.  
then i wanted to extend my treeview class with a print capability,

but then i confronted with the fact, that i don’t know how many pages do  
i need to print,  
since i wanna have header, footer on the pages, and i don’t wanna miss  
a character, so i set ellipsize to off and wrap to word,  
but then i can’t estimate the height of my text lines,  
so i have to lay the table to on the context so i can count the pages  
and feed printoperation with it before printing, as it is in the docs.

i realized, i’m moving my code from draw\_page event into paginate event.  
and then i found that in paginate i have the context only of the first  
page,  
while in draw\_page i could use the context of all the pages one by one.

first i thought i’ll have to construct the print context for  
printoperation in paginate and have only a cairo::context.stroke per  
page in the draw\_page event.  
but that can’t be done.

so i concluded that i have to lay all my headers, footers, table  
headers, some rows of table data on paginate’s context  
only to count how many table rows i was able to lay, so clear the  
context an continue the laying of pango stuff like it was a the next  
page.  
and the end i get the number of my pages, and can start  
printoperation.run, who will call draw\_page and i can lay everything  
again and stroke at the end.

but then it came to me, this has to be wrong, this is not how it’s  
supposed to be.

so please, anyone, who has a clue about printing like this, point me to  
the right direction.

thanks,  
Balint

---

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [November 21, 2006, 5:25pm UTC](https://www.ruby-forum.com/t/printoperation-dunno-howto/76674/2 "2006-11-21T17:25:51Z")

</div>

Hi,

On Mon, 20 Nov 2006 11:16:55 +0200  
Dobai-Pataky BÃ¡lint [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> hi,
> 
> i managed to print some pages, header, footer positioned, i liked it,  
> almost felt it done.  
> then i wanted to extend my treeview class with a print capability,

> so please, anyone, who has a clue about printing like this, point me to  
> the right direction.

I think you are the first person who try Gtk::Print and stuffs on this  
list.  
So I think anyone can’t help you now.  
I hope you find a good solution by yourself and introduce your code  
anywhere.

* * *

Take Surveys. Earn Cash. Influence the Future of IT  
Join [SourceForge.net](http://SourceForge.net)’s Techsay panel and you’ll get the chance to share  
your  
opinions on IT & business topics through brief surveys - and earn cash  
[http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)

---

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [November 22, 2006, 6:29am UTC](https://www.ruby-forum.com/t/printoperation-dunno-howto/76674/3 "2006-11-22T06:29:56Z")

</div>

Hi,

Masao M. wrote:

> I think you are the first person who try Gtk::Print and stuffs on this list.  
> So I think anyone can’t help you now.  
> I hope you find a good solution by yourself and introduce your code  
> anywhere.  
> Dobai-Pataky, it would be great if you could send sample scripts for the  
> Gtk::Print stuff. It is just not obvious how the different classes work  
> together.

Mathieu

* * *

Take Surveys. Earn Cash. Influence the Future of IT  
Join [SourceForge.net](http://SourceForge.net)’s Techsay panel and you’ll get the chance to share  
your  
opinions on IT & business topics through brief surveys - and earn cash  
[http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)

---

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [November 22, 2006, 9:14am UTC](https://www.ruby-forum.com/t/printoperation-dunno-howto/76674/4 "2006-11-22T09:14:06Z")

</div>

* * *

Take Surveys. Earn Cash. Influence the Future of IT  
Join [SourceForge.net](http://SourceForge.net)’s Techsay panel and you’ll get the chance to share  
your  
opinions on IT & business topics through brief surveys - and earn cash  
[http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)

---

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [November 23, 2006, 9:21am UTC](https://www.ruby-forum.com/t/printoperation-dunno-howto/76674/5 "2006-11-23T09:21:08Z")

</div>

* * *

Take Surveys. Earn Cash. Influence the Future of IT  
Join [SourceForge.net](http://SourceForge.net)’s Techsay panel and you’ll get the chance to share  
your  
opinions on IT & business topics through brief surveys - and earn cash  
[http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)

---

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [November 23, 2006, 10:43am UTC](https://www.ruby-forum.com/t/printoperation-dunno-howto/76674/6 "2006-11-23T10:43:18Z")

</div>

Hi Bálint,

Dobai-Pataky Bálint wrote:

> any progress Mathieu?  
> Sorry about your first name in my last email!

I have tested your script today. I have two bugs with it:

1. If I try to print some text in a PDF file (I don’t have a printer) I  
get :  
mathieu@mathieu-desktop:~/Desktop$ ruby printer2.rb

- status changed: Initial state
- status changed: Preparing to print  
begin-print called  
paginate called, pages: 0  
printer2.rb:33: undefined method `get_page_height' for nil:NilClass from printer2.rb:145 from printer2.rb:173 /usr/local/lib/site_ruby/1.8/glib2.rb:45:in `exit’: exit  
from /usr/local/lib/site\_ruby/1.8/glib2.rb:45:in  
`exit_application' from printer2.rb:33:in `run’  
from printer2.rb:145  
from printer2.rb:173

1. Whenever I click “cancel” or “apply” on the page setup dialog, I get:  
mathieu@mathieu-desktop:~/Desktop$ ruby printer2.rb  
ruby: symbol lookup error:  
/usr/local/lib/site\_ruby/1.8/i486-linux/gtk2.so: undefined symbol:  
GOBJ2RVALU

When I compile Ruby/Gtk, I indeed get some warnings about GOBJ2RVALU  
(and other things). See below. I can’t figure out why this macro is said  
to be missing since looking at rbgobject.h, it is actually defined!

mathieu@mathieu-desktop:~/Desktop/sources/ruby-gnome2-cvs/gtk$ make \>  
/dev/null  
rbgdkpixbuf.c: In function `pixbuf_s_from_drawable': rbgdkpixbuf.c:118: warning: implicit declaration of function `GOBJ2RVALU’  
rbgtkpagesetup.c: In function `ps_copy': rbgtkpagesetup.c:31: warning: implicit declaration of function `GOBJ2RVALU’  
rbgtkpapersize.c: In function `ps_initialize': rbgtkpapersize.c:29: warning: implicit declaration of function `RVAL2CSTR2’  
rbgtkpapersize.c:29: warning: passing arg 1 of `gtk_paper_size_new' makes pointer from integer without a cast rbgtkprintcontext.c: In function `pc\_create\_pango\_context’:  
rbgtkprintcontext.c:69: warning: implicit declaration of function  
`GOBJ2RVALU' rbgtkprintoperation.c: In function `po\_run\_page\_setup\_dialog’:  
rbgtkprintoperation.c:113: warning: implicit declaration of function  
`GOBJ2RVALU' rbgtkprintsettings.c: In function `ps\_copy’:  
rbgtkprintsettings.c:32: warning: implicit declaration of function  
`GOBJ2RVALU' rbgtkprintsettings.c: In function `ps\_set’:  
rbgtkprintsettings.c:50: warning: implicit declaration of function  
`RVAL2CSTR2' rbgtkprintsettings.c:50: warning: passing arg 3 of `gtk\_print\_settings\_set’ makes pointer from integer without a cast  
rbgtkprintsettings.c: In function `ps_set_printer': rbgtkprintsettings.c:257: warning: passing arg 2 of `gtk\_print\_settings\_set\_printer’ makes pointer from integer without a  
cast  
rbgtkprintsettings.c: In function `ps_set_default_source': rbgtkprintsettings.c:518: warning: passing arg 2 of `gtk\_print\_settings\_set\_default\_source’ makes pointer from integer  
without a cast  
rbgtkprintsettings.c: In function `ps_set_media_type': rbgtkprintsettings.c:531: warning: passing arg 2 of `gtk\_print\_settings\_set\_media\_type’ makes pointer from integer without a  
cast  
rbgtkprintsettings.c: In function `ps_set_dither': rbgtkprintsettings.c:544: warning: passing arg 2 of `gtk\_print\_settings\_set\_dither’ makes pointer from integer without a  
cast  
rbgtkprintsettings.c: In function `ps_set_finishings': rbgtkprintsettings.c:557: warning: passing arg 2 of `gtk\_print\_settings\_set\_finishings’ makes pointer from integer without a  
cast  
rbgtkprintsettings.c: In function `ps_set_output_bin': rbgtkprintsettings.c:570: warning: passing arg 2 of `gtk\_print\_settings\_set\_output\_bin’ makes pointer from integer without a  
cast  
rbgtkrecentchooserdialog.c: In function `rcd_initialize': rbgtkrecentchooserdialog.c:31: warning: implicit declaration of function `RVAL2CSTR2’  
rbgtkwidget.c: In function `widget_create_pango_context': rbgtkwidget.c:617: warning: implicit declaration of function `GOBJ2RVALU’  
rbgtkwidget.c: In function `widget_create_pango_layout': rbgtkwidget.c:635: warning: implicit declaration of function `RVAL2CSTR2’  
rbgtkwidget.c:635: warning: passing arg 2 of  
`gtk_widget_create_pango_layout' makes pointer from integer without a cast rbgtkwidget.c: In function `widget\_render\_icon’:  
rbgtkwidget.c:648: warning: passing arg 4 of `gtk\_widget\_render\_icon’  
makes pointer from integer without a cast

Mathieu

* * *

Take Surveys. Earn Cash. Influence the Future of IT  
Join [SourceForge.net](http://SourceForge.net)’s Techsay panel and you’ll get the chance to share  
your  
opinions on IT & business topics through brief surveys - and earn cash  
[http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)

---

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [November 23, 2006, 12:05pm UTC](https://www.ruby-forum.com/t/printoperation-dunno-howto/76674/7 "2006-11-23T12:05:32Z")

</div>

* * *

Take Surveys. Earn Cash. Influence the Future of IT  
Join [SourceForge.net](http://SourceForge.net)’s Techsay panel and you’ll get the chance to share  
your  
opinions on IT & business topics through brief surveys - and earn cash  
[http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)

---

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [November 24, 2006, 3:08am UTC](https://www.ruby-forum.com/t/printoperation-dunno-howto/76674/8 "2006-11-24T03:08:30Z")

</div>

Hi,

Masao M. wrote:

> Hi,
> 
> GOBJ2RVALU, RVAL2CSTR2 are defined in the latest Ruby/GLib2.  
> Compile the CVS version of Ruby/GLib2 first, then recompile Ruby/GTK2  
> again.

No it does not work even though I am compiling the up-to-date CVS  
version. Strange.

Mathieu

* * *

Take Surveys. Earn Cash. Influence the Future of IT  
Join [SourceForge.net](http://SourceForge.net)’s Techsay panel and you’ll get the chance to share  
your  
opinions on IT & business topics through brief surveys - and earn cash  
[http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)

---

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [November 23, 2006, 2:27pm UTC](https://www.ruby-forum.com/t/printoperation-dunno-howto/76674/9 "2006-11-23T14:27:55Z")

</div>

Hi,

GOBJ2RVALU, RVAL2CSTR2 are defined in the latest Ruby/GLib2.  
Compile the CVS version of Ruby/GLib2 first, then recompile Ruby/GTK2  
again.

On Thu, 23 Nov 2006 17:42:32 +0800  
Mathieu B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> mathieu@mathieu-desktop:~/Desktop$ ruby printer2.rb  
> from printer2.rb:145  
> to be missing since looking at rbgobject.h, it is actually defined!  
> makes pointer from integer without a cast  
> rbgtkprintsettings.c:50: warning: implicit declaration of function  
> rbgtkprintsettings.c: In function `ps_set_media_type': rbgtkprintsettings.c: In function `ps\_set\_output\_bin’:  
> rbgtkwidget.c:635: warning: passing arg 2 of  
> opinions on IT & business topics through brief surveys - and earn cash  
> [http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)
> 
> * * *
> 
> ruby-gnome2-devel-en mailing list  
> removed\_email\_address@domain.invalid  
> [ruby-gnome2-devel-en List Signup and Options](https://lists.sourceforge.net/lists/listinfo/ruby-gnome2-devel-en)

* * *

Take Surveys. Earn Cash. Influence the Future of IT  
Join [SourceForge.net](http://SourceForge.net)’s Techsay panel and you’ll get the chance to share  
your  
opinions on IT & business topics through brief surveys - and earn cash  
[http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)

---

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [November 24, 2006, 7:49am UTC](https://www.ruby-forum.com/t/printoperation-dunno-howto/76674/10 "2006-11-24T07:49:00Z")

</div>

* * *

Take Surveys. Earn Cash. Influence the Future of IT  
Join [SourceForge.net](http://SourceForge.net)’s Techsay panel and you’ll get the chance to share  
your  
opinions on IT & business topics through brief surveys - and earn cash  
[http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)

---

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [November 24, 2006, 9:04pm UTC](https://www.ruby-forum.com/t/printoperation-dunno-howto/76674/11 "2006-11-24T21:04:47Z")

</div>

* * *

Take Surveys. Earn Cash. Influence the Future of IT  
Join [SourceForge.net](http://SourceForge.net)’s Techsay panel and you’ll get the chance to share  
your  
opinions on IT & business topics through brief surveys - and earn cash  
[http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV](http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV)
