Printing with GTK/Cairo produces only empty pages

2013-10-14 Thread Satz Klauer
Hi,

I try to print some vector data using GTK/Cairo. Unfortunately my
printer only produces empty pages, means there is no print operation,
the paper sheets are just moved.

That's how I'm initialising everything:

GtkPrintOperation *op;

op = gtk_print_operation_new();
gtk_print_operation_set_allow_async(op,TRUE);
gtk_print_operation_set_n_pages(op, 1);
gtk_print_operation_set_unit (op,GTK_UNIT_POINTS);
g_signal_connect (op, draw_page, G_CALLBACK(draw_page), NULL);
gtk_print_operation_run (op, GTK_PRINT_OPERATION_ACTION_PRINT,NULL, NULL);

The print-callback (which is called successfuly) looks like this:

static void draw_page (GtkPrintOperation *operation,GtkPrintContext
*context,int page_nr)
{
   GtkPrintSettings *settings;

   cairo_t *cr = gtk_print_context_get_cairo_context (context);
   settings = gtk_print_operation_get_print_settings (operation);
   cairo_set_source_rgb(dc,0,0,0);
   cairo_set_line_width(dc,m_data-config.m_linewidth);

   cairo_move_to (cr,x0,y0);
   cairo_line_to (cr,x1,y1);
   cairo_line_to (cr,x2,y2);
   ...
   // some more lines...
}

What could be missing here? Do I have to close/finish the drawing
operation somehow?

Thanks!
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Printing with GTK/Cairo produces only empty pages

2013-10-14 Thread Chris Vine
On Mon, 14 Oct 2013 19:34:53 +0200
Satz Klauer satzkla...@googlemail.com wrote:

 Hi,
 
 I try to print some vector data using GTK/Cairo. Unfortunately my
 printer only produces empty pages, means there is no print operation,
 the paper sheets are just moved.
 
 That's how I'm initialising everything:
 
 GtkPrintOperation *op;
 
 op = gtk_print_operation_new();
 gtk_print_operation_set_allow_async(op,TRUE);
 gtk_print_operation_set_n_pages(op, 1);
 gtk_print_operation_set_unit (op,GTK_UNIT_POINTS);
 g_signal_connect (op, draw_page, G_CALLBACK(draw_page), NULL);
 gtk_print_operation_run (op, GTK_PRINT_OPERATION_ACTION_PRINT,NULL,
 NULL);
 
 The print-callback (which is called successfuly) looks like this:
 
 static void draw_page (GtkPrintOperation *operation,GtkPrintContext
 *context,int page_nr)
 {
GtkPrintSettings *settings;
 
cairo_t *cr = gtk_print_context_get_cairo_context (context);
settings = gtk_print_operation_get_print_settings (operation);
cairo_set_source_rgb(dc,0,0,0);
cairo_set_line_width(dc,m_data-config.m_linewidth);
 
cairo_move_to (cr,x0,y0);
cairo_line_to (cr,x1,y1);
cairo_line_to (cr,x2,y2);
...
// some more lines...
 }
 
 What could be missing here? Do I have to close/finish the drawing
 operation somehow?

That depends on what you are trying to draw.  I suspect you are looking
for cairo_stroke(), but you could also consider cairo_fill(). Note also
the *_preserve() variants.

Chris
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Printing with GTK/Cairo produces only empty pages

2013-10-14 Thread Satz Klauer
I just want to draw a bunch of lines  - simple polygons, no filling...

On Mon, Oct 14, 2013 at 7:55 PM, Chris Vine ch...@cvine.freeserve.co.uk wrote:
 On Mon, 14 Oct 2013 19:34:53 +0200
 Satz Klauer satzkla...@googlemail.com wrote:

 Hi,

 I try to print some vector data using GTK/Cairo. Unfortunately my
 printer only produces empty pages, means there is no print operation,
 the paper sheets are just moved.

 That's how I'm initialising everything:

 GtkPrintOperation *op;

 op = gtk_print_operation_new();
 gtk_print_operation_set_allow_async(op,TRUE);
 gtk_print_operation_set_n_pages(op, 1);
 gtk_print_operation_set_unit (op,GTK_UNIT_POINTS);
 g_signal_connect (op, draw_page, G_CALLBACK(draw_page), NULL);
 gtk_print_operation_run (op, GTK_PRINT_OPERATION_ACTION_PRINT,NULL,
 NULL);

 The print-callback (which is called successfuly) looks like this:

 static void draw_page (GtkPrintOperation *operation,GtkPrintContext
 *context,int page_nr)
 {
GtkPrintSettings *settings;

cairo_t *cr = gtk_print_context_get_cairo_context (context);
settings = gtk_print_operation_get_print_settings (operation);
cairo_set_source_rgb(dc,0,0,0);
cairo_set_line_width(dc,m_data-config.m_linewidth);

cairo_move_to (cr,x0,y0);
cairo_line_to (cr,x1,y1);
cairo_line_to (cr,x2,y2);
...
// some more lines...
 }

 What could be missing here? Do I have to close/finish the drawing
 operation somehow?

 That depends on what you are trying to draw.  I suspect you are looking
 for cairo_stroke(), but you could also consider cairo_fill(). Note also
 the *_preserve() variants.

 Chris
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Re: Printing with gtk+, cairo and pango - need to iterate glyphsand problems with pango attributes

2009-07-15 Thread joel
I tried the code below on debian GNU/Linux unstable as well on win32. The output
was a bit different but didn't work on both operating systems.


#include gtk/gtk.h

void
begin_print(GtkPrintOperation *operation, GtkPrintContext *context)
{
  gtk_print_operation_set_n_pages(operation, 1);
  gtk_print_operation_set_use_full_page(operation, FALSE);
} 

void
draw_page(GtkPrintOperation *operation, GtkPrintContext *context, gint page_nr)
{
  PangoLayout *layout, *test_attribute, *test_iterateing;
  PangoFontDescription *desc;
  PangoAttrList *attr_list;
  PangoAttribute *attribute;
  PangoLayoutRun *run;
  cairo_t *cr;
  GSList *list0, *list1;
  PangoRectangle logical_rect;
  double x_off, y_off;
  int width, height;
  guint i;

  cr = gtk_print_context_get_cairo_context(context);
  layout = gtk_print_context_create_pango_layout(context);

  desc = pango_font_description_from_string(Sans 12\0);

  /* test attribute */
  test_attribute = pango_layout_copy(layout);
  pango_layout_set_text(test_attribute, Title\nsecondary text\0, -1);
  pango_layout_set_font_description(test_attribute, desc);

  attr_list = pango_attr_list_new();

  attribute = pango_attr_size_new(14);
  attribute-start_index = 0;
  attribute-end_index = 6;
  pango_attr_list_insert(attr_list, attribute);

  attribute = pango_attr_size_new(7);
  attribute-start_index = 6;
  attribute-end_index = 15;
  pango_attr_list_insert(attr_list, attribute);

  pango_layout_set_attributes(test_attribute, attr_list);

  cairo_set_source_rgb(cr, 0.0, 0.0, 0.0);
  cairo_move_to(cr, 0.0, 0.0);
  pango_cairo_show_layout(cr, test_attribute);


  /* test iterateing */
  test_iterateing = pango_layout_copy(layout);
  pango_layout_set_text(test_attribute, 0123456789\0, -1);
  pango_layout_set_font_description(test_iterateing, desc);

  list0 = pango_layout_get_lines(layout);

  pango_layout_get_size(test_attribute, width, height);
  height *= PANGO_SCALE;
  y_off = (double) height;

  while(list0 != NULL){
list1 = ((PangoLayoutLine *) (list0-data))-runs;
x_off = 0.0;

while(list1 != NULL){
  run = (PangoLayoutRun *) list1-data;
  
  pango_glyph_string_extents(run-glyphs, run-item-analysis.font,
 NULL, logical_rect);

  cairo_move_to(cr, x_off, y_off);
  pango_cairo_show_glyph_string(cr, run-item-analysis.font, run-glyphs);
  
  x_off += (double)(logical_rect.width * PANGO_SCALE);
  list1 = list1-next;
}

y_off += height;
list0 = list0-next;
  }

  g_object_unref(layout);
  g_object_unref(test_attribute);
  g_object_unref(test_iterateing);

  pango_font_description_free(desc);
} 

void
end_print(GtkPrintOperation *operation, GtkPrintContext *context)
{
}

gboolean
delete_event(GtkWindow *window, gpointer data)
{
  gtk_main_quit();

  return(FALSE);
}

void
button_clicked(GtkButton *button, gpointer data)
{
  GtkWindow *window;
  GtkPrintOperation *operation;
  GError *error;

  window = (GtkWindow *) gtk_widget_get_toplevel((GtkWidget *) button);
  
  operation = gtk_print_operation_new();
  error = NULL;
 
  g_signal_connect((GObject *) operation, begin-print\0,
   G_CALLBACK (begin_print), window);
  g_signal_connect((GObject *) operation, draw-page\0,
   G_CALLBACK (draw_page), window);
  g_signal_connect((GObject *) operation, end-print\0,
   G_CALLBACK (end_print), window);

  gtk_print_operation_run(operation,
  GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
  window,
  error);

  if(error != NULL){
GtkWidget *dialog;
   
dialog = gtk_message_dialog_new ((GtkWindow *) window, 0,
 GTK_MESSAGE_ERROR,
 GTK_BUTTONS_OK,
 An error occured while trying to 
print:\0);
gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
error-message);
   
gtk_dialog_run(GTK_DIALOG (dialog));
gtk_widget_destroy(dialog);
   
g_error_free(error);
  }

  g_object_unref(operation);
}


int
main(int argc, char **argv)
{
  GtkWindow *window;
  GtkButton *button;
  
  gtk_init(argc, argv);

  window = (GtkWindow *) gtk_window_new(GTK_WINDOW_TOPLEVEL);
  g_signal_connect((GObject *) window, delete-event\0,
   G_CALLBACK(delete_event), NULL);

  button = (GtkButton *) gtk_button_new_with_label(print\0);
  gtk_container_add((GtkContainer *) window, (GtkWidget *) button);
  g_signal_connect((GObject *) button, clicked\0,
   G_CALLBACK(button_clicked), NULL);

  gtk_widget_show_all((GtkWidget *) window);

  gtk_main();

  return(0);
}



___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: Printing with gtk+, cairo and pango - need to iterate glyphsand problems with pango attributes

2009-07-15 Thread Behdad Esfahbod

I get the attached output which looks fine.
Which versions of pango and cairo are you using on Linux?

behdad

On 07/15/2009 11:05 AM, j...@weedlight.ch wrote:

I tried the code below on debian GNU/Linux unstable as well on win32. The output
was a bit different but didn't work on both operating systems.


#includegtk/gtk.h

void
begin_print(GtkPrintOperation *operation, GtkPrintContext *context)
{
   gtk_print_operation_set_n_pages(operation, 1);
   gtk_print_operation_set_use_full_page(operation, FALSE);
}

void
draw_page(GtkPrintOperation *operation, GtkPrintContext *context, gint page_nr)
{
   PangoLayout *layout, *test_attribute, *test_iterateing;
   PangoFontDescription *desc;
   PangoAttrList *attr_list;
   PangoAttribute *attribute;
   PangoLayoutRun *run;
   cairo_t *cr;
   GSList *list0, *list1;
   PangoRectangle logical_rect;
   double x_off, y_off;
   int width, height;
   guint i;

   cr = gtk_print_context_get_cairo_context(context);
   layout = gtk_print_context_create_pango_layout(context);

   desc = pango_font_description_from_string(Sans 12\0);

   /* test attribute */
   test_attribute = pango_layout_copy(layout);
   pango_layout_set_text(test_attribute, Title\nsecondary text\0, -1);
   pango_layout_set_font_description(test_attribute, desc);

   attr_list = pango_attr_list_new();

   attribute = pango_attr_size_new(14);
   attribute-start_index = 0;
   attribute-end_index = 6;
   pango_attr_list_insert(attr_list, attribute);

   attribute = pango_attr_size_new(7);
   attribute-start_index = 6;
   attribute-end_index = 15;
   pango_attr_list_insert(attr_list, attribute);

   pango_layout_set_attributes(test_attribute, attr_list);

   cairo_set_source_rgb(cr, 0.0, 0.0, 0.0);
   cairo_move_to(cr, 0.0, 0.0);
   pango_cairo_show_layout(cr, test_attribute);


   /* test iterateing */
   test_iterateing = pango_layout_copy(layout);
   pango_layout_set_text(test_attribute, 0123456789\0, -1);
   pango_layout_set_font_description(test_iterateing, desc);

   list0 = pango_layout_get_lines(layout);

   pango_layout_get_size(test_attribute,width,height);
   height *= PANGO_SCALE;
   y_off = (double) height;

   while(list0 != NULL){
 list1 = ((PangoLayoutLine *) (list0-data))-runs;
 x_off = 0.0;

 while(list1 != NULL){
   run = (PangoLayoutRun *) list1-data;

   pango_glyph_string_extents(run-glyphs, run-item-analysis.font,
 NULL,logical_rect);

   cairo_move_to(cr, x_off, y_off);
   pango_cairo_show_glyph_string(cr, run-item-analysis.font, run-glyphs);

   x_off += (double)(logical_rect.width * PANGO_SCALE);
   list1 = list1-next;
 }

 y_off += height;
 list0 = list0-next;
   }

   g_object_unref(layout);
   g_object_unref(test_attribute);
   g_object_unref(test_iterateing);

   pango_font_description_free(desc);
}

void
end_print(GtkPrintOperation *operation, GtkPrintContext *context)
{
}

gboolean
delete_event(GtkWindow *window, gpointer data)
{
   gtk_main_quit();

   return(FALSE);
}

void
button_clicked(GtkButton *button, gpointer data)
{
   GtkWindow *window;
   GtkPrintOperation *operation;
   GError *error;

   window = (GtkWindow *) gtk_widget_get_toplevel((GtkWidget *) button);

   operation = gtk_print_operation_new();
   error = NULL;

   g_signal_connect((GObject *) operation, begin-print\0,
   G_CALLBACK (begin_print), window);
   g_signal_connect((GObject *) operation, draw-page\0,
   G_CALLBACK (draw_page), window);
   g_signal_connect((GObject *) operation, end-print\0,
   G_CALLBACK (end_print), window);

   gtk_print_operation_run(operation,
  GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
  window,
error);

   if(error != NULL){
 GtkWidget *dialog;

 dialog = gtk_message_dialog_new ((GtkWindow *) window, 0,
 GTK_MESSAGE_ERROR,
 GTK_BUTTONS_OK,
 An error occured while trying to 
print:\0);
 gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
error-message);

 gtk_dialog_run(GTK_DIALOG (dialog));
 gtk_widget_destroy(dialog);

 g_error_free(error);
   }

   g_object_unref(operation);
}


int
main(int argc, char **argv)
{
   GtkWindow *window;
   GtkButton *button;

   gtk_init(argc,argv);

   window = (GtkWindow *) gtk_window_new(GTK_WINDOW_TOPLEVEL);
   g_signal_connect((GObject *) window, delete-event\0,
   G_CALLBACK(delete_event), NULL);

   button = (GtkButton *) gtk_button_new_with_label(print\0);
   gtk_container_add((GtkContainer *) window, (GtkWidget *) button);
   g_signal_connect((GObject *) button, clicked\0,
   G_CALLBACK(button_clicked), NULL);

   gtk_widget_show_all((GtkWidget *) window);

   gtk_main();

   return(0);
}



___
gtk-list mailing list

Re: Re: Printing with gtk+, cairo and pango - need to iterate glyphs and problems with pango attributes

2009-07-15 Thread joel krähemann
No, the output isn't fine it shows only the last part of the text  
Title\nsecondary text\0 and the string 0123456789 isn't displayed at
all. 


On debian GNU/Linux unstable:

  Name: Pango
  pango_module_version=1.6.0
  Version: 1.24.4

  Name: cairo
  Version: 1.8.8

  Name: Pango Cairo
  Version: 1.24.4

  Name: GTK+
  gtk_binary_version=2.10.0
  Version: 2.16.4


on win32 (gtk-dev-2.12.9-win32-2.exe):

  Name: Pango
  pango_module_version=1.6.0
  Version: 1.20.2

  Name: Pango Cairo
  Version: 1.20.2
  
  Name: cairo
  Version: 1.6.4

  Name: GTK+
  gtk_binary_version=2.10.0
  Version: 2.12.9


Am Mittwoch, den 15.07.2009, 13:34 -0400 schrieb Behdad Esfahbod:
 I get the attached output which looks fine.
 Which versions of pango and cairo are you using on Linux?
 
 behdad


___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: Printing with gtk+, cairo and pango - need to iterate glyphs and problems with pango attributes

2009-07-15 Thread Behdad Esfahbod

1) pango_attr_size_new() takes size in pango units, so, replace:

pango_attr_size_new(14) with pango_attr_size_new(14*PANGO_SCALE)

2) pango_layout_get_size() and pango_glyph_string_extents() returns sizes in 
pango units, so instead of multiplying by PANGO_SCALE you should be dividing 
by PANGO_SCALE.


3) You set the string 0123456789 on the PangoLayout named test_iterating, 
but iterate over the one named layout.



I also suggest using PangoLayoutIter for iterating, and also use the baseline 
value instead of line hight for correct line positioning.


behdad

On 07/15/2009 04:43 PM, joel krähemann wrote:

No, the output isn't fine it shows only the last part of the text
Title\nsecondary text\0 and the string 0123456789 isn't displayed at
all.


On debian GNU/Linux unstable:

   Name: Pango
   pango_module_version=1.6.0
   Version: 1.24.4

   Name: cairo
   Version: 1.8.8

   Name: Pango Cairo
   Version: 1.24.4

   Name: GTK+
   gtk_binary_version=2.10.0
   Version: 2.16.4


on win32 (gtk-dev-2.12.9-win32-2.exe):

   Name: Pango
   pango_module_version=1.6.0
   Version: 1.20.2

   Name: Pango Cairo
   Version: 1.20.2

   Name: cairo
   Version: 1.6.4

   Name: GTK+
   gtk_binary_version=2.10.0
   Version: 2.12.9


Am Mittwoch, den 15.07.2009, 13:34 -0400 schrieb Behdad Esfahbod:

I get the attached output which looks fine.
Which versions of pango and cairo are you using on Linux?

behdad



___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: Printing with gtk+, cairo and pango - need to iterate glyphs and problems with pango attributes

2009-07-13 Thread Behdad Esfahbod

Uh, looks like may be a bug with our win32 backends.  Can you try on Linux?

behdad

On 07/09/2009 08:07 AM, j...@weedlight.ch wrote:

Hi
I'm trying to print a form which I developed with gtk+. I developed it on m$
Vista with mingw and glade libraries from sourceforge.net. I didn't write it on
GNU/Linux because it should run on win32. That's why I installed ghostscript and
FreePDF to print to PDF to save toner and paper.
I don't understand why the following codes don't work and I have a need for both
for simple usage and iterating glyphs!

First I tried this whereby every letter seems to be painted at same position:

void
ar_print_draw_page(ArPrint *print, GtkPrintOperation *operation, GtkPrintContext
*context, gint page_nr)
{
   cairo_t *cr;
   PangoLayout *layout;
   PangoFontDescription *desc;
   PangoAttrList *attribute_list;
   PangoAttribute *attribute;
   PangoLayoutRun *run;
   PangoRectangle logical_rect;
   GList *list_line, *list_run;
   guint x_offset, y_offset;
   void ar_print_draw_page_header(){
 gdouble info_width;
 gdouble font_size, offset;

 info_width = (print-content_width) * (5.35 / 18.5);
 offset = 0.0;

 cairo_set_source_rgb(cr, 0.0, 0.0, 1.0);

 cairo_rectangle(cr, print-padding_left + info_width, print-padding_top,
print-content_width - info_width, print-header_height);
 cairo_fill(cr);

 cairo_rectangle(cr, print-padding_left, print-padding_top, info_width,
print-header_height);
 cairo_stroke(cr);

 layout = gtk_print_context_create_pango_layout(context);
 //layout = pango_layout_new(pango_cairo_create_context(cr));
 pango_layout_set_text(layout, Title\nsecondary text\0, -1);

 desc = pango_font_description_from_string(Arial 10\0);
 pango_layout_set_font_description(layout, desc);
 //pango_font_description_free(desc);

 attribute_list = pango_attr_list_new();

 attribute = pango_attr_size_new(9);
 attribute-start_index = 0;
 attribute-end_index = 6;
 pango_attr_list_insert(attribute_list, attribute);

 attribute = pango_attr_size_new(7);
 attribute-start_index = 6;
 attribute-end_index = 15;
 pango_attr_list_insert(attribute_list, attribute);

 pango_layout_set_attributes(layout, attribute_list);
 pango_layout_set_alignment(layout, PANGO_ALIGN_LEFT);

 pango_layout_context_changed(layout);

 cairo_set_source_rgb(cr, 0.0, 0.0, 0.0);
 cairo_move_to(cr, print-padding_left, print-padding_top);
 pango_cairo_show_layout(cr, layout);

 g_object_unref(layout);

   }
   void ar_print_draw_page_body(){
   }
   void ar_print_draw_page_footer(){
   }

   cr = gtk_print_context_get_cairo_context(context);

   ar_print_draw_page_header();
   ar_print_draw_page_body();
   ar_print_draw_page_footer();
}

furthermore I tried something like following and got the same result as above:

void
ar_print_draw_page(ArPrint *print, GtkPrintOperation *operation, GtkPrintContext
*context, gint page_nr)
{
  ...

  list0 = pango_layout_get_lines(layout);

  y_off = 0;

  for(i = 0; i  rows  list0 != NULL; i++){
list1 = ((PangoLayoutLine *) (list0-data))-runs;
x_off = 0;

while(list1 != NULL){
  run = (PangoLayoutRun *) list1-data;

  pango_glyph_string_extents(run-glyphs, run-item-analysis.font,
 NULL,logical_rect);

  pango_cairo_show_glyph_string(cr, run-item-analysis.font, run-glyphs);

  x_off += logical_rect.width;
  list1 = list1-next;
}

y_off += height;
list0 = list0-next;
  }

   ...
}

___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


Printing with gtk+, cairo and pango - need to iterate glyphs and problems with pango attributes

2009-07-09 Thread joel
Hi
I'm trying to print a form which I developed with gtk+. I developed it on m$
Vista with mingw and glade libraries from sourceforge.net. I didn't write it on
GNU/Linux because it should run on win32. That's why I installed ghostscript and
FreePDF to print to PDF to save toner and paper.
I don't understand why the following codes don't work and I have a need for both
for simple usage and iterating glyphs!

First I tried this whereby every letter seems to be painted at same position:

void
ar_print_draw_page(ArPrint *print, GtkPrintOperation *operation, GtkPrintContext
*context, gint page_nr)
{
  cairo_t *cr;
  PangoLayout *layout;
  PangoFontDescription *desc;
  PangoAttrList *attribute_list;
  PangoAttribute *attribute;
  PangoLayoutRun *run;
  PangoRectangle logical_rect;
  GList *list_line, *list_run;
  guint x_offset, y_offset;
  void ar_print_draw_page_header(){
gdouble info_width;
gdouble font_size, offset;

info_width = (print-content_width) * (5.35 / 18.5);
offset = 0.0;

cairo_set_source_rgb(cr, 0.0, 0.0, 1.0);

cairo_rectangle(cr, print-padding_left + info_width, print-padding_top,
print-content_width - info_width, print-header_height);
cairo_fill(cr);

cairo_rectangle(cr, print-padding_left, print-padding_top, info_width,
print-header_height);
cairo_stroke(cr);

layout = gtk_print_context_create_pango_layout(context);
//layout = pango_layout_new(pango_cairo_create_context(cr));
pango_layout_set_text(layout, Title\nsecondary text\0, -1);

desc = pango_font_description_from_string(Arial 10\0);
pango_layout_set_font_description(layout, desc);
//pango_font_description_free(desc);

attribute_list = pango_attr_list_new();

attribute = pango_attr_size_new(9);
attribute-start_index = 0;
attribute-end_index = 6;
pango_attr_list_insert(attribute_list, attribute);

attribute = pango_attr_size_new(7);
attribute-start_index = 6;
attribute-end_index = 15;
pango_attr_list_insert(attribute_list, attribute);

pango_layout_set_attributes(layout, attribute_list);
pango_layout_set_alignment(layout, PANGO_ALIGN_LEFT);

pango_layout_context_changed(layout);

cairo_set_source_rgb(cr, 0.0, 0.0, 0.0);
cairo_move_to(cr, print-padding_left, print-padding_top);
pango_cairo_show_layout(cr, layout);

g_object_unref(layout);

  }
  void ar_print_draw_page_body(){
  }
  void ar_print_draw_page_footer(){
  }

  cr = gtk_print_context_get_cairo_context(context);

  ar_print_draw_page_header();
  ar_print_draw_page_body();
  ar_print_draw_page_footer();
}

furthermore I tried something like following and got the same result as above:

void
ar_print_draw_page(ArPrint *print, GtkPrintOperation *operation, GtkPrintContext
*context, gint page_nr)
{
 ...

 list0 = pango_layout_get_lines(layout);

 y_off = 0;

 for(i = 0; i  rows  list0 != NULL; i++){
   list1 = ((PangoLayoutLine *) (list0-data))-runs;
   x_off = 0;

   while(list1 != NULL){
 run = (PangoLayoutRun *) list1-data;

 pango_glyph_string_extents(run-glyphs, run-item-analysis.font,
NULL, logical_rect);

 pango_cairo_show_glyph_string(cr, run-item-analysis.font, run-glyphs);

 x_off += logical_rect.width;
 list1 = list1-next;
   }

   y_off += height;
   list0 = list0-next;
 }

  ...
}

___
gtk-list mailing list
gtk-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-list


Pango and Printing with GTK#

2008-04-20 Thread John M. Anderson
I'm trying to do some printing with a mix of pango and cairo within
GTK#. My big issue right now is I can't find a
way to reliable measure a font so I can figure out how many characters
will fit inside the Layout so I can manage how
many pages will need to be printed and wrap the text properly.

Right now I can get it to wrap the text automatically for me by giving
the layout a width but then I can't figure out a way
to measure the strings to know how many pages i'm going to have.

Is there standard functionality in Pango to do all this?
___
gtk-i18n-list mailing list
gtk-i18n-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-i18n-list


Re: Pango and Printing with GTK#

2008-04-20 Thread Behdad Esfahbod
On Sun, 2008-04-20 at 01:06 -0600, John M. Anderson wrote:
 I'm trying to do some printing with a mix of pango and cairo within
 GTK#. My big issue right now is I can't find a
 way to reliable measure a font so I can figure out how many characters
 will fit inside the Layout so I can manage how
 many pages will need to be printed and wrap the text properly.

The only way to see how many pages a text would take is to put the text
into a layout, get an iterator for the layout, go over the lines, get
line heights, and stuff pages with lines.  There's no such thing as how
many characters will fit inside the layout.

 Right now I can get it to wrap the text automatically for me by giving
 the layout a width but then I can't figure out a way
 to measure the strings to know how many pages i'm going to have.
 
 Is there standard functionality in Pango to do all this?

-- 
behdad
http://behdad.org/

Those who would give up Essential Liberty to purchase a little
 Temporary Safety, deserve neither Liberty nor Safety.
-- Benjamin Franklin, 1759

___
gtk-i18n-list mailing list
gtk-i18n-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-i18n-list


Printing with gtk on windows

2005-07-21 Thread Razvan Gavril
I need to do some printing in a gtk application that runs on windows os and 
i can't find any starting point to look for documentation. Can anyone help 
me ? 
-- 
Razvan Gavril
[EMAIL PROTECTED]
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Printing in GTK+

2004-10-19 Thread Carl B. Constantine
* Roger Leigh ([EMAIL PROTECTED]) wrote:
 Some of the recent (paid) work I've done with GTK+ has involved output
 to receipt printers for point of sale applications, where this sort of
 thing would have been quite useful.  As it was, I just used normal
 pipes.  And all the reporting used groff as a backend; a GTK+ frontend
 is also planned.  For Gimp-Print, the libgimpprintui library provides
 its own print dialog, providing full control over the printer, but
 it's currently dependent upon libgimpprint and so would only be good
 for client-side processing.  I talked with Jody about moving some of
 the widgets into libgimpprintui if they would be useful (once the code
 has been cleaned up--it's not currently modular enough).

What kind of label (POS) printer are you using? I'll need to get
something I know works.

 The PostScript rendering API could use the same GIOChannel to send the
 print job--it would just be an extra layer that you have the choice of
 using or not as you see fit (and the fact that there are two layers
 could be hidden by the rendering API).

That would be nice.

-- 
 .''`.  Carl B. Constantine
: :' : [EMAIL PROTECTED]
`. `'GnuPG: 135F FC30 7A02 B0EB 61DB  34E3 3AF1 DC6C 9F7A 3FF8
  `-  Debian GNU/Linux -- The power of freedom
  Claiming that your operating system is the best in the world because more
  people use it is like saying McDonalds makes the best food in the world.
___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: Printing in GTK+

2004-10-16 Thread Owen Taylor
On Fri, 2004-10-15 at 22:53 +0100, Roger Leigh wrote:
 Owen Taylor [EMAIL PROTECTED] writes:
 
  On Thu, 2004-10-14 at 21:24 -0700, Todd Fisher wrote:
  What about a cross-platform method for printing?
 
  There's some discussion of possible GTK+ future printing interfaces
  in my GUADEC paper:
 
  http://people.redhat.com/otaylor/guadec5/
 
  I think a fairly simple printing interface does makes sense for
  GTK+, but it's been long blocked on not having a rendering API
  that's suitable for printing.
 
 It looks like there's a nice clean separation between two pieces:
 
 1) A print dialog for selecting printers, paper sizes, printer
features etc.
 
 2) A rendering API to produce PS, PDF, SVG etc.
 
 Most programs will want (1), but only some will need (2).  Most of the
 programs I've written don't have any use for rendering (making no use
 of the Canvas): they either output plaintext or do their own
 printer-specific control, or use groff or TeX as the rendering
 mechanism.  They would still find (1) very useful, to select the
 output destination, paper size, print quality etc.

I think you are looking at a somewhat distorted sample of
applications. :-). I think most application writers who want to print
something would like to write code to draw what they want to print.
Preferably using the same API as they are using to draw to the screen.

Because it's been needed for libgnomeprint for things like ggv and 
gpdf, it's likely that a GTK+ API would contain a backdoor for sending
raw PS to the selected printer, but that can't be cross-platform, and it
certainly wouldn't be the primary interface.

 With regards to (1), I did have a chat with Jody Goldberg about this
 in Bordeaux this summer.  One issue we have in the Gimp-Print project
 is that the current mechanism of describing printer capabilities with
 PPDs is no longer sufficient to describe a Gimp-Print driver, which
 supports curves and value ranges which the PPD spec can't cope with.
 This becomes a problem when you want to edit them in a portable
 manner: currently only the GIMP Print UI is capable of this, leaving
 CUPS and LPRng users unable to access the extended functionality on
 offer.

I  this all can be kept hidden from applications so that if a better
replacement for PPD files starts being used, it can just be dropped in
transparently.

Regards,
Owen



signature.asc
Description: This is a digitally signed message part
___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: Printing in GTK+

2004-10-16 Thread Roger Leigh
Owen Taylor [EMAIL PROTECTED] writes:

 On Fri, 2004-10-15 at 22:53 +0100, Roger Leigh wrote:
 Owen Taylor [EMAIL PROTECTED] writes:
 
  There's some discussion of possible GTK+ future printing interfaces
  in my GUADEC paper:
 
  http://people.redhat.com/otaylor/guadec5/

I forgot to say thanks for writing that; I found it very interesting.

  I think a fairly simple printing interface does makes sense for
  GTK+, but it's been long blocked on not having a rendering API
  that's suitable for printing.
 
 It looks like there's a nice clean separation between two pieces:
 
 1) A print dialog for selecting printers, paper sizes, printer
features etc.
 
 2) A rendering API to produce PS, PDF, SVG etc.
 
 Most programs will want (1), but only some will need (2).  Most of the
 programs I've written don't have any use for rendering (making no use
 of the Canvas): they either output plaintext or do their own
 printer-specific control, or use groff or TeX as the rendering
 mechanism.  They would still find (1) very useful, to select the
 output destination, paper size, print quality etc.

 I think you are looking at a somewhat distorted sample of
 applications. :-). I think most application writers who want to print
 something would like to write code to draw what they want to print.
 Preferably using the same API as they are using to draw to the screen.

That's very true.  However, not all GTK+ applications will be using
the Canvas.

 Because it's been needed for libgnomeprint for things like ggv and 
 gpdf, it's likely that a GTK+ API would contain a backdoor for sending
 raw PS to the selected printer, but that can't be cross-platform, and it
 certainly wouldn't be the primary interface.

That's good to know.  There's no requirement for print schedulers such
as CUPS to accept /only/ PostScript.  You can also have raw, PCL,
ESC/P or whatever you like as the input or output format, and convert
using filters as you like.  For many bespoke applications, PostScript
will not the output format of choice.  There are also a lot of
printers which are not capable of printing postscript (since they
aren't raster devices), or haven't got enough resolution to produce
legible output.

Some of the recent (paid) work I've done with GTK+ has involved output
to receipt printers for point of sale applications, where this sort of
thing would have been quite useful.  As it was, I just used normal
pipes.  And all the reporting used groff as a backend; a GTK+ frontend
is also planned.  For Gimp-Print, the libgimpprintui library provides
its own print dialog, providing full control over the printer, but
it's currently dependent upon libgimpprint and so would only be good
for client-side processing.  I talked with Jody about moving some of
the widgets into libgimpprintui if they would be useful (once the code
has been cleaned up--it's not currently modular enough).


I'd prefer the Print dialog to provide the programmer with a some sort
of structure detailing the printer name, capabilities and job options
(printer settings chosen by the user), and a means to get a GIOChannel
for sending output to from that structure, e.g.

GtkPrinterSettings *
gtk_print_dialog_get_printer_settings(GtkPrintDialog *dialog);

GIOChannel *
gtk_printer_settings_get_output_channel(GtkPrinterSettings *settings);

The PostScript rendering API could use the same GIOChannel to send the
print job--it would just be an extra layer that you have the choice of
using or not as you see fit (and the fact that there are two layers
could be hidden by the rendering API).

I'll take a closer look at libgnomeprint(ui) to see what you are
currently doing in this respect.  I've not had a close look for quite
a while, and I understand there's quite a lot of work been done since
then!

 With regards to (1), I did have a chat with Jody Goldberg about this
 in Bordeaux this summer.  One issue we have in the Gimp-Print project
 is that the current mechanism of describing printer capabilities with
 PPDs is no longer sufficient to describe a Gimp-Print driver, which
 supports curves and value ranges which the PPD spec can't cope with.
 This becomes a problem when you want to edit them in a portable
 manner: currently only the GIMP Print UI is capable of this, leaving
 CUPS and LPRng users unable to access the extended functionality on
 offer.

 I  this all can be kept hidden from applications so that if a better
 replacement for PPD files starts being used, it can just be dropped in
 transparently.

This is *very* hard because both the spooler and UI need to use the
same mechanism for describing job options, and PPDs have become the
de-facto standard.  For the most part it's OK as long as the options
are simple lists of choices.  When you want to to anything more
complex, you are straight into non-portable hacks, and unfortunately
PPDs are the only portable cross-platform option at this time...

For things like the Print dialog, using libraries like libcups to talk
directly

Re: Printing in GTK+

2004-10-15 Thread Roger Leigh
Todd Fisher [EMAIL PROTECTED] writes:

 would printing to a spooler be cross platform?  I mean would this process
 you describe be similar if I wanted to print in win32 as it is in Linux?

Pass.  I do know that you can open LPT1 etc. and print to them.  It
might go via the spooler.  You might also be able to open
\\host\printer.


-- 
Roger Leigh

Printing on GNU/Linux?  http://gimp-print.sourceforge.net/
GPG Public Key: 0x25BFB848.  Please sign and encrypt your mail.
___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: Printing in GTK+

2004-10-15 Thread Roger Leigh
Russell Shaw [EMAIL PROTECTED] writes:

 Roger Leigh wrote:

 Your best bet is to use a spooler.  This also makes networked
 operation totally transparent, and is far more flexible.  You can use
 libcups, lpc or lpstat etc. to get a list of all available printers if
 the user needs to choose one.

 It's really quite easy to generate and output postscript, which can
 then be printed to any postscript printer or non postscript printer
 via ghostscript. Look for the postscript blue book and red book.
 HP PCL 5 might be an option too.

That's very true.  However, in this case the device is a low-quality
thermal line printer which prints 8x16 char cells, and so isn't really
suitable as a PostScript output device--it might not support raster
output, and it likely needs full manual control in the application
generating the output (or something like my groescp groff device for
simple troff formatting).


Regards,
Roger

-- 
Roger Leigh

Printing on GNU/Linux?  http://gimp-print.sourceforge.net/
GPG Public Key: 0x25BFB848.  Please sign and encrypt your mail.
___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: Printing in GTK+

2004-10-15 Thread Roger Leigh
Carl B. Constantine [EMAIL PROTECTED] writes:

 * Roger Leigh ([EMAIL PROTECTED]) wrote:
 Carl B. Constantine [EMAIL PROTECTED] writes:
 
 By a POS printer, I take that to mean a 40 col receipt printer sort of
 thing.  These are basic devices which are basically ASCII thermal
 printers plus some additional control codes and possibly some extra
 bitmap raster graphics mode.  For these you just send the control
 codes inline with the text you're printing to either (1) or (2) above.
 Your program is entirely responsible for the formatting, layout and
 cutting etc.

 yes, that's pretty much what I mean. What do I use to do layout and
 formatting before dumping to the printer?

You need to do it as you're generating the output.  For example, if I
want bold text, I might have to send

\033\005This is bold text\0330\006 and this is plain text\n

Where ESC 5 and ESC 6 turn bold on and off respectively.  The
control codes required are printer-dependent.  It's likely it uses the
Epson EPC/P, ESP/POS or Star control codes.  Your manual should tell
you, and the manufacturer should supply the programmer's manual.

If you intend to support multiple printers, you can abstract the
interface through e.g. a pure virtual base class which provides a
printing interface which derived classes specialise to provide custom
functionality.

 Where would I find information on the extra control codes? I'm sure not
 all printer manufactureres publish this sort of thing. How does that
 work with CUPS?

The manufacturers have to, otherwise it's useless.  Your manual should
say which standards it supports, and the command reference for that
standard should be available.

For CUPS, set up a raw queue (no filter driver) so what you send is
simply queued and piped direct to the printer with no special
processing.

 Your best bet is to use a spooler.  This also makes networked
 operation totally transparent, and is far more flexible.  You can use
 libcups, lpc or lpstat etc. to get a list of all available printers if
 the user needs to choose one.

 Ok, so I probably will use a print spooler (CUPS), what do I need to do?
 I'll look at the CUPS docs, but some fast direct pointers are nice.

Install it, then have a look at http://localhost:631/
LPRng is also a very good alternative.


If you have other printing questions, the lists on linuxprinting.org,
or comp.os.linux.misc/comp.os.linux.development.apps are good places
to ask (since this is not really a GTK+ topic).


Regards,
Roger

-- 
Roger Leigh

Printing on GNU/Linux?  http://gimp-print.sourceforge.net/
GPG Public Key: 0x25BFB848.  Please sign and encrypt your mail.
___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: Printing in GTK+

2004-10-15 Thread Owen Taylor
On Thu, 2004-10-14 at 21:24 -0700, Todd Fisher wrote:
 What about a cross-platform method for printing?

There's some discussion of possible GTK+ future printing interfaces
in my GUADEC paper:

http://people.redhat.com/otaylor/guadec5/

I think a fairly simple printing interface does makes sense for
GTK+, but it's been long blocked on not having a rendering API
that's suitable for printing.

Regards,
Owen



signature.asc
Description: This is a digitally signed message part
___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: Printing in GTK+

2004-10-15 Thread Roger Leigh
Owen Taylor [EMAIL PROTECTED] writes:

 On Thu, 2004-10-14 at 21:24 -0700, Todd Fisher wrote:
 What about a cross-platform method for printing?

 There's some discussion of possible GTK+ future printing interfaces
 in my GUADEC paper:

 http://people.redhat.com/otaylor/guadec5/

 I think a fairly simple printing interface does makes sense for
 GTK+, but it's been long blocked on not having a rendering API
 that's suitable for printing.

It looks like there's a nice clean separation between two pieces:

1) A print dialog for selecting printers, paper sizes, printer
   features etc.

2) A rendering API to produce PS, PDF, SVG etc.

Most programs will want (1), but only some will need (2).  Most of the
programs I've written don't have any use for rendering (making no use
of the Canvas): they either output plaintext or do their own
printer-specific control, or use groff or TeX as the rendering
mechanism.  They would still find (1) very useful, to select the
output destination, paper size, print quality etc.


With regards to (1), I did have a chat with Jody Goldberg about this
in Bordeaux this summer.  One issue we have in the Gimp-Print project
is that the current mechanism of describing printer capabilities with
PPDs is no longer sufficient to describe a Gimp-Print driver, which
supports curves and value ranges which the PPD spec can't cope with.
This becomes a problem when you want to edit them in a portable
manner: currently only the GIMP Print UI is capable of this, leaving
CUPS and LPRng users unable to access the extended functionality on
offer.


Regards,
Roger

-- 
Roger Leigh

Printing on GNU/Linux?  http://gimp-print.sourceforge.net/
GPG Public Key: 0x25BFB848.  Please sign and encrypt your mail.
___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: Printing in GTK+

2004-10-15 Thread Todd Fisher
would printing to a spooler be cross platform?  I mean would this process
you describe be similar if I wanted to print in win32 as it is in Linux?
thanks,
todd
Roger Leigh wrote:
Carl B. Constantine [EMAIL PROTECTED] writes:
 

I have some data I want to print out in my application. How do I do it?
To make things a little different, I *might* print to one of those POS
type printers (USB) not a regular printer.
Pointers? Which classes do I need to use?
   

GTK+ itself doesn't currently offer any printing support, so the
question doesn't really involve GTK+ directly.  You need to either
1) Open the printer device (e.g. /dev/usb/lp0) and write data to it.
2) Open a pipe to the printer spooler (e.g. lpr -P queuename)
  and then write the job data and close the connection.
By a POS printer, I take that to mean a 40 col receipt printer sort of
thing.  These are basic devices which are basically ASCII thermal
printers plus some additional control codes and possibly some extra
bitmap raster graphics mode.  For these you just send the control
codes inline with the text you're printing to either (1) or (2) above.
Your program is entirely responsible for the formatting, layout and
cutting etc.
For the work I do, I send jobs to a receipt printer via CUPS.  After
completion of a transaction, the receipt gets printed after a barely
noticeable delay ( 0.5s).
Your best bet is to use a spooler.  This also makes networked
operation totally transparent, and is far more flexible.  You can use
libcups, lpc or lpstat etc. to get a list of all available printers if
the user needs to choose one.
Regards,
Roger
 


___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


Printing in GTK+

2004-10-14 Thread Carl B. Constantine
I have some data I want to print out in my application. How do I do it?
To make things a little different, I *might* print to one of those POS
type printers (USB) not a regular printer.

Pointers? Which classes do I need to use?

Thanks.

-- 
 .''`.  Carl B. Constantine
: :' : [EMAIL PROTECTED]
`. `'GnuPG: 135F FC30 7A02 B0EB 61DB  34E3 3AF1 DC6C 9F7A 3FF8
  `-  Debian GNU/Linux -- The power of freedom
  Claiming that your operating system is the best in the world because more
  people use it is like saying McDonalds makes the best food in the world.
___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: Printing in GTK+

2004-10-14 Thread Roger Leigh
Carl B. Constantine [EMAIL PROTECTED] writes:

 I have some data I want to print out in my application. How do I do it?
 To make things a little different, I *might* print to one of those POS
 type printers (USB) not a regular printer.

 Pointers? Which classes do I need to use?

GTK+ itself doesn't currently offer any printing support, so the
question doesn't really involve GTK+ directly.  You need to either

1) Open the printer device (e.g. /dev/usb/lp0) and write data to it.
2) Open a pipe to the printer spooler (e.g. lpr -P queuename)
   and then write the job data and close the connection.

By a POS printer, I take that to mean a 40 col receipt printer sort of
thing.  These are basic devices which are basically ASCII thermal
printers plus some additional control codes and possibly some extra
bitmap raster graphics mode.  For these you just send the control
codes inline with the text you're printing to either (1) or (2) above.
Your program is entirely responsible for the formatting, layout and
cutting etc.


For the work I do, I send jobs to a receipt printer via CUPS.  After
completion of a transaction, the receipt gets printed after a barely
noticeable delay ( 0.5s).


Your best bet is to use a spooler.  This also makes networked
operation totally transparent, and is far more flexible.  You can use
libcups, lpc or lpstat etc. to get a list of all available printers if
the user needs to choose one.


Regards,
Roger

-- 
Roger Leigh

Printing on GNU/Linux?  http://gimp-print.sourceforge.net/
GPG Public Key: 0x25BFB848.  Please sign and encrypt your mail.
___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: Printing in GTK+

2004-10-14 Thread Russell Shaw
Roger Leigh wrote:
Carl B. Constantine [EMAIL PROTECTED] writes:

I have some data I want to print out in my application. How do I do it?
To make things a little different, I *might* print to one of those POS
type printers (USB) not a regular printer.
Pointers? Which classes do I need to use?

GTK+ itself doesn't currently offer any printing support, so the
question doesn't really involve GTK+ directly.  You need to either
1) Open the printer device (e.g. /dev/usb/lp0) and write data to it.
2) Open a pipe to the printer spooler (e.g. lpr -P queuename)
   and then write the job data and close the connection.
By a POS printer, I take that to mean a 40 col receipt printer sort of
thing.  These are basic devices which are basically ASCII thermal
printers plus some additional control codes and possibly some extra
bitmap raster graphics mode.  For these you just send the control
codes inline with the text you're printing to either (1) or (2) above.
Your program is entirely responsible for the formatting, layout and
cutting etc.
For the work I do, I send jobs to a receipt printer via CUPS.  After
completion of a transaction, the receipt gets printed after a barely
noticeable delay ( 0.5s).
Your best bet is to use a spooler.  This also makes networked
operation totally transparent, and is far more flexible.  You can use
libcups, lpc or lpstat etc. to get a list of all available printers if
the user needs to choose one.
It's really quite easy to generate and output postscript, which can
then be printed to any postscript printer or non postscript printer
via ghostscript. Look for the postscript blue book and red book.
HP PCL 5 might be an option too.
IIRC, there's some new way of printing from X windows directly (Xprt).
Stay away from win gdi printers.
http://linuxfinances.info/info/printing.html
http://members.tripod.com/rpragana/gdiprinters.html
http://www-cdf.fnal.gov/offline/PostScript/AdobePS.html
http://www-cdf.fnal.gov/offline/PostScript/AdobePS.html#SamplePostScriptfiles
___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: Printing in GTK+

2004-10-14 Thread Carl B. Constantine
* Roger Leigh ([EMAIL PROTECTED]) wrote:
 Carl B. Constantine [EMAIL PROTECTED] writes:
 
  I have some data I want to print out in my application. How do I do it?
  To make things a little different, I *might* print to one of those POS
  type printers (USB) not a regular printer.
 
  Pointers? Which classes do I need to use?
 
 GTK+ itself doesn't currently offer any printing support, so the
 question doesn't really involve GTK+ directly.  You need to either
 
 1) Open the printer device (e.g. /dev/usb/lp0) and write data to it.
 2) Open a pipe to the printer spooler (e.g. lpr -P queuename)
and then write the job data and close the connection.

Thanks for clearing this up.

 By a POS printer, I take that to mean a 40 col receipt printer sort of
 thing.  These are basic devices which are basically ASCII thermal
 printers plus some additional control codes and possibly some extra
 bitmap raster graphics mode.  For these you just send the control
 codes inline with the text you're printing to either (1) or (2) above.
 Your program is entirely responsible for the formatting, layout and
 cutting etc.

yes, that's pretty much what I mean. What do I use to do layout and
formatting before dumping to the printer?

Where would I find information on the extra control codes? I'm sure not
all printer manufactureres publish this sort of thing. How does that
work with CUPS?


 For the work I do, I send jobs to a receipt printer via CUPS.  After
 completion of a transaction, the receipt gets printed after a barely
 noticeable delay ( 0.5s).
 
 
 Your best bet is to use a spooler.  This also makes networked
 operation totally transparent, and is far more flexible.  You can use
 libcups, lpc or lpstat etc. to get a list of all available printers if
 the user needs to choose one.

Ok, so I probably will use a print spooler (CUPS), what do I need to do?
I'll look at the CUPS docs, but some fast direct pointers are nice.

Thanks in advance.


-- 
 .''`.  Carl B. Constantine
: :' : [EMAIL PROTECTED]
`. `'GnuPG: 135F FC30 7A02 B0EB 61DB  34E3 3AF1 DC6C 9F7A 3FF8
  `-  Debian GNU/Linux -- The power of freedom
  Claiming that your operating system is the best in the world because more
  people use it is like saying McDonalds makes the best food in the world.
___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: Printing in GTK+

2004-10-14 Thread Igor Gorbounov
Carl B. Constantine wrote:
* Roger Leigh ([EMAIL PROTECTED]) wrote:
 

Carl B. Constantine [EMAIL PROTECTED] writes:
   

I have some data I want to print out in my application. How do I do it?
To make things a little different, I *might* print to one of those POS
type printers (USB) not a regular printer.
Pointers? Which classes do I need to use?
 

GTK+ itself doesn't currently offer any printing support, so the
question doesn't really involve GTK+ directly.  You need to either
1) Open the printer device (e.g. /dev/usb/lp0) and write data to it.
2) Open a pipe to the printer spooler (e.g. lpr -P queuename)
  and then write the job data and close the connection.
   

Thanks for clearing this up.
 

Why, you could use gnomeprint and gnomeprintui. There are a lot of 
formatting abilities.
   Igor Gorbounov
___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: Printing in GTK+

2004-10-14 Thread Todd Fisher
What about a cross-platform method for printing?
-todd
Igor Gorbounov wrote:
Carl B. Constantine wrote:
* Roger Leigh ([EMAIL PROTECTED]) wrote:
 

Carl B. Constantine [EMAIL PROTECTED] writes:
  

I have some data I want to print out in my application. How do I do 
it?
To make things a little different, I *might* print to one of those POS
type printers (USB) not a regular printer.

Pointers? Which classes do I need to use?

GTK+ itself doesn't currently offer any printing support, so the
question doesn't really involve GTK+ directly.  You need to either
1) Open the printer device (e.g. /dev/usb/lp0) and write data to it.
2) Open a pipe to the printer spooler (e.g. lpr -P queuename)
  and then write the job data and close the connection.
  

Thanks for clearing this up.
 

Why, you could use gnomeprint and gnomeprintui. There are a lot of 
formatting abilities.
   Igor Gorbounov
___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: Printing in GTK+

2004-10-14 Thread Igor Gorbounov
Todd Fisher wrote:
What about a cross-platform method for printing?
-todd
Perhaps, someone will port gnomeprint to other platforms? :-)
   Igor
___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


Printing in GTK+ environment

2003-07-14 Thread Igor Gorbounov
Hi, All!
I need a hint about printing. I need some ways of printing for my plots 
(build
by using GtkDrawingArea) and reports (build and viewed through GtkTreeView).
No idea where to dig to...
   Hopefully,
  Igor Gorbounov

___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


RE: [gtkmm] Printing in GTK+ environment

2003-07-14 Thread Murray . Cumming
 From: Igor Gorbounov [mailto:[EMAIL PROTECTED] 
 
 Hi, All!
 I need a hint about printing. I need some ways of printing 
 for my plots 
 (build
 by using GtkDrawingArea) and reports (build and viewed 
 through GtkTreeView).
 No idea where to dig to...
 Hopefully,
Igor Gorbounov

I would investigate libgnomeprint and libgnomeprintui.

Murray Cumming
[EMAIL PROTECTED]
www.murrayc.com
Remember to use the Reply To All feature with mailing lists.
___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


Re: [gtkmm] Printing in GTK+ environment

2003-07-14 Thread Igor Gorbounov
[EMAIL PROTECTED] wrote:

From: Igor Gorbounov [mailto:[EMAIL PROTECTED] 

Hi, All!
I need a hint about printing. I need some ways of printing 
for my plots 
(build
by using GtkDrawingArea) and reports (build and viewed 
through GtkTreeView).
No idea where to dig to...
   Hopefully,
  Igor Gorbounov
   

I would investigate libgnomeprint and libgnomeprintui.

Murray Cumming
 

So it's not wraped for C++ yet...
   Igor Gorbounov
 



___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


RE: [gtkmm] Printing in GTK+ environment

2003-07-14 Thread Murray . Cumming
 From: Igor Gorbounov [mailto:[EMAIL PROTECTED] 
 I would investigate libgnomeprint and libgnomeprintui.
 
 So it's not wraped for C++ yet...
 Igor Gorbounov

No, it's not. That should be quite easy to do, by looking at existing *mm
projects.

Murray Cumming
[EMAIL PROTECTED]
www.murrayc.com 
___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list


Printing in GTK?

2002-07-16 Thread rhfreeman

Hi folks,

Just need a bit of help here! I've got some GdkPixmaps in GTK 1.2 that I
need to print out. I've looked into GdkMagicK but that doesn't seem to be
being developed any further and also looking into using GIMP-print but that
could be too complex for what I need.

Does anyone else have any suggestions as to what I could use to print these
from within GTK? Would porting my app to GTK 2.0 help me at all?

Thanks!

Rich
___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list