Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

GTk Printing a obe page document

38 views
Skip to first unread message

ldries46

unread,
Jan 25, 2023, 8:15:36 AM1/25/23
to
In the same program I can print multiple page documents but one page
documents are not printed.
Set_N_Pages (Print_Op, nr_Pages); in this statement nr_Pages is filled
correctly. What can I do or where should I look for some kind of bug.

ldries46

unread,
Jan 25, 2023, 9:47:53 AM1/25/23
to
Op 25-1-2023 om 14:15 schreef ldries46:
Testing with a single page file resulted in an output of two pages.

ldries46

unread,
Jan 25, 2023, 11:10:42 AM1/25/23
to
Op 25-1-2023 om 14:15 schreef ldries46:

ldries46

unread,
Jan 26, 2023, 6:03:52 AM1/26/23
to
Op 25-1-2023 om 17:10 schreef ldries46:
I stop with question and will start a new one because I think the
original question was not clear enough and had a type error in the
original title.

ldries46

unread,
Jan 26, 2023, 6:40:41 AM1/26/23
to
I have a problem printing one page documents in GTK 3.0.
Documents with more than one page are correctly printed but one page documents are not printed.
Because using the debugger in GNAT Studio 23.0w (20220512)  is sometimes a problem I have used printed some results during running to the GTK textview. I found that the program not even reaches Draw_Page from Connect_and_Run.
My question is what should I do to also correctly print one page documents.
For your information On_Print the code is:

        Set_N_Pages (Print_Op, nr_Pages);
        Set_Use_Full_Page(Print_Op, true);
        Set_Unit (Print_Op, points);
        --DEBUG-------------------------------------------------------------------
        Insert_At_Cursor(Text_Buffers(nb), buf_string(To_Unbounded_String("Set_Unit (Print_Op, points)"), 0, true));
        Insert_At_Cursor(Text_Buffers(nb), buf_string(To_Unbounded_String("nr_Pages       =") & Gint'image(nr_Pages) & " Filetype " & Windows'image(nb), 0, true));
        Insert_At_Cursor(Text_Buffers(nb), buf_string(To_Unbounded_String("Ofirst_line    =") & integer'image(first_line), 0, true));
        Insert_At_Cursor(Text_Buffers(nb), buf_string(To_Unbounded_String("last_line      =") & integer'image(last_line), 0, true));
        Insert_At_Cursor(Text_Buffers(nb), buf_string(To_Unbounded_String("delta_lines    =") & integer'image(delta_lines), 0, true));
        Insert_At_Cursor(Text_Buffers(nb), buf_string(To_Unbounded_String("Number         =") & long_float'image(Number), 0, true));
        --------------------------------------------------------------------------
        Print_Op.Set_Print_Settings(Print_Set);
-------------------------------------------------------------------
--   procedure On_Draw_Page
--      (Self  : not null access Gtk_Print_Operation_Record;
--       Call  : Cb_Gtk_Print_Operation_Gtk_Print_Context_Gint_Void;
--       After : Boolean := False);
--------------------------------------------------------------------
        --DEBUG-------------------------------------------------------------------
        Insert_At_Cursor(Text_Buffers(nb), buf_string(To_Unbounded_String("Print_Op.Set_Print_Settings(Print_Set)"), 0, true));
        Insert_At_Cursor(Text_Buffers(nb), buf_string(To_Unbounded_String("nr_Pages       =") & Gint'image(nr_Pages) & " Filetype " & Windows'image(nb), 0, true));
        Insert_At_Cursor(Text_Buffers(nb), buf_string(To_Unbounded_String("Ofirst_line    =") & integer'image(first_line), 0, true));
        Insert_At_Cursor(Text_Buffers(nb), buf_string(To_Unbounded_String("last_line      =") & integer'image(last_line), 0, true));
        Insert_At_Cursor(Text_Buffers(nb), buf_string(To_Unbounded_String("delta_lines    =") & integer'image(delta_lines), 0, true));
        Insert_At_Cursor(Text_Buffers(nb), buf_string(To_Unbounded_String("Number         =") & long_float'image(Number), 0, true));
        --------------------------------------------------------------------------
        On_Draw_Page(Print_Op, Draw);
        --DEBUG-------------------------------------------------------------------
        Insert_At_Cursor(Text_Buffers(nb), buf_string(To_Unbounded_String("On_Draw_Page(Print_Op, Draw)"), 0, true));
        Insert_At_Cursor(Text_Buffers(nb), buf_string(To_Unbounded_String("nr_Pages       =") & Gint'image(nr_Pages) & " Filetype " & Windows'image(nb), 0, true));
        Insert_At_Cursor(Text_Buffers(nb), buf_string(To_Unbounded_String("Ofirst_line    =") & integer'image(first_line), 0, true));
        Insert_At_Cursor(Text_Buffers(nb), buf_string(To_Unbounded_String("last_line      =") & integer'image(last_line), 0, true));
        Insert_At_Cursor(Text_Buffers(nb), buf_string(To_Unbounded_String("delta_lines    =") & integer'image(delta_lines), 0, true));
        Insert_At_Cursor(Text_Buffers(nb), buf_string(To_Unbounded_String("Number         =") & long_float'image(Number), 0, true));
        --------------------------------------------------------------------------
        Result := Connect_and_Run(Print_Op ,Action_Print_Dialog, Main_Window);
--        --DEBUG-------------------------------------------------------------------
        Insert_At_Cursor(Text_Buffers(nb), buf_string(To_Unbounded_String("Connect_and_Run(Print_Op ,Action_Print_Dialog, Main_Window)"), 0, true));
        Insert_At_Cursor(Text_Buffers(nb), buf_string(To_Unbounded_String("nr_Pages       =") & Gint'image(nr_Pages) & " Filetype " & Windows'image(nb), 0, true));
        Insert_At_Cursor(Text_Buffers(nb), buf_string(To_Unbounded_String("Ofirst_line    =") & integer'image(first_line), 0, true));
        Insert_At_Cursor(Text_Buffers(nb), buf_string(To_Unbounded_String("last_line      =") & integer'image(last_line), 0, true));
        Insert_At_Cursor(Text_Buffers(nb), buf_string(To_Unbounded_String("delta_lines    =") & integer'image(delta_lines), 0, true));
        Insert_At_Cursor(Text_Buffers(nb), buf_string(To_Unbounded_String("Number         =") & long_float'image(Number), 0, true));
        --------------------------------------------------------------------------

In Draw_Page also someinformation lines are presented:

      nr := first_line;
      Cr := Get_Cairo_Context (Context);
      Set_Source_Rgb (Cr, 0.0, 0.0, 0.0);
      Select_font_face(Cr, "Consolas", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
      Set_Font_Size(Cr, GDouble(10));
      if nr = 1 then
         pagenr := 1;
      else
         pagenr := pagenr + 1;
      end if;
      if pagenr rem 2 = 1 then
         width := 70;
      else
         width := 40;
      end if;
      if last_page_line > last_line then
         last_page_line := last_line;
      end if;
      len := 3;
      nr1 := 10;
      while last_line > nr1 - 1 loop
         nr1 := nr1 * 10;
         len := len + 1;
      end loop;
     --DEBUG-------------------------------------------------------------------
     Insert_At_Cursor(Text_Buffers(Window_Type), buf_string(To_Unbounded_String("Draw_Page "), 0, true));
     Insert_At_Cursor(Text_Buffers(Window_Type), buf_string(To_Unbounded_String("pagenr         = ") & integer'image(pagenr), 0, true));
     Insert_At_Cursor(Text_Buffers(Window_Type), buf_string(To_Unbounded_String("first_line     = " & integer'image(first_line) & " Buffer = " & Windows'image(Window_Type)), 0, true));
     Insert_At_Cursor(Text_Buffers(Window_Type), buf_string(To_Unbounded_String("last_line      = ") & integer'image(last_line), 0, true));
     Insert_At_Cursor(Text_Buffers(Window_Type), buf_string(To_Unbounded_String("last_page_line = ") & integer'image(last_page_line), 0, true));
     --------------------------------------------------------------------------


With a one page document I got:
Set_Unit (Print_Op, points)
nr_Pages       = 1 Filetype GL
Ofirst_line    = 1
last_line      = 15
delta_lines    = 56
Number         = 1.00000000000000E+00
Print_Op.Set_Print_Settings(Print_Set)
nr_Pages       = 1 Filetype GL
Ofirst_line    = 1
last_line      = 15
delta_lines    = 56
Number         = 1.00000000000000E+00
On_Draw_Page(Print_Op, Draw)
nr_Pages       = 1 Filetype GL
Ofirst_line    = 1
last_line      = 15
delta_lines    = 56
Number         = 1.00000000000000E+00
Connect_and_Run(Print_Op ,Action_Print_Dialog, Main_Window)
nr_Pages       = 1 Filetype GL
Ofirst_line    = 1
last_line      = 15
delta_lines    = 56
Number         = 1.00000000000000E+00

With a Multipage document I got:
Set_Unit (Print_Op, points)
nr_Pages       = 2 Filetype BI
Ofirst_line    = 1
last_line      = 68
delta_lines    = 56
Number         = 2.00000000000000E+00
Print_Op.Set_Print_Settings(Print_Set)
nr_Pages       = 2 Filetype BI
Ofirst_line    = 1
last_line      = 68
delta_lines    = 56
Number         = 2.00000000000000E+00
On_Draw_Page(Print_Op, Draw)
nr_Pages       = 2 Filetype BI
Ofirst_line    = 1
last_line      = 68
delta_lines    = 56
Number         = 2.00000000000000E+00
Draw_Page
pagenr         =  1
first_line     =  1 Buffer = BI
last_line      =  68
last_page_line =  57
Draw_Page
pagenr         =  2
first_line     =  58 Buffer = BI
last_line      =  68
last_page_line =  68
Connect_and_Run(Print_Op ,Action_Print_Dialog, Main_Window)
nr_Pages       = 2 Filetype BI
Ofirst_line    = 69
last_line      = 68
delta_lines    = 56
Number         = 2.00000000000000E+00

0 new messages