Infinite loop on print page, cannot find e.HasMorePages Property on drawing document

62 views
Skip to first unread message

Anthony Rivera

unread,
Aug 27, 2014, 3:31:39 PM8/27/14
to eto-...@googlegroups.com
Eto is a beatiful and organize way of programming, I have been playing with eto from about 8 months and this framework just do everything necesary for a cross platfom application!

I have the problem when drawing a document the e.HasMorePages is not visible and cannot stop the document drawing. How can I stop the document and tell the amount of page to draw using ETO?

I have made a lot of documents using the drawing namespace on windows also using the print preview class with the document I created

Here is sample I am using for test purpose


 private void doc1_PrintPage(object sender, Forms.PrintPageEventArgs e)
 {
        e.Graphics.DrawText(new Drawing.Font(new Drawing.FontFamily("Arial"), (float)12.0), Drawing.Colors.AliceBlue, new Drawing.PointF(10, 10), "Test");
        
        //Property Not found
        //e.HasMorePages = false;
        //Here the method loops infinitely
 }

how can I fix this problem?

Thanks in advance! :D

curtis

unread,
Aug 29, 2014, 12:53:35 PM8/29/14
to eto-...@googlegroups.com
Hi,

There is no 'HasMorePages', you must specify the number of pages ahead of time with the PrintDocument.PageCount property.

Hope this helps!
Curtis.

Anthony Rivera

unread,
Aug 29, 2014, 1:11:21 PM8/29/14
to eto-...@googlegroups.com
So something like this should work?

int PageIndex = 1;
 private void doc1_PrintPage(object sender, Forms.PrintPageEventArgs e)
 {
       if(PageIndex == 1) 
       {
          //pages #1
          e.Graphics.DrawText(new Drawing.Font(new Drawing.FontFamily("Arial"), (float)12.0), Drawing.Colors.AliceBlue, new Drawing.PointF(10, 10), "Test page 1");
          PageIndex++;
        }
        else if ()PageIndex == 2)
        {
          //pages #2
          e.Graphics.DrawText(new Drawing.Font(new Drawing.FontFamily("Arial"), (float)12.0), Drawing.Colors.AliceBlue, new Drawing.PointF(10, 10), "Test page 2");
        }
 }

Anthony Rivera

unread,
Aug 29, 2014, 1:33:07 PM8/29/14
to eto-...@googlegroups.com
yeah my code worked thanks Curtis! Eto is Awesome!

curtis

unread,
Aug 29, 2014, 1:35:03 PM8/29/14
to eto-...@googlegroups.com
Hi Anthony,

Use e.CurrentPage, which will give you the current page that is printing.

You can also use e.PageSize to determine where to draw things.  The page size will likely be different based on the platform you are using, so it is pretty important to use this.

Hope this helps!
Curtis.

Anthony Rivera

unread,
Aug 29, 2014, 1:45:15 PM8/29/14
to eto-...@googlegroups.com
 ohh yeah that is a better option thanks! my code worked thanks!! :D
Reply all
Reply to author
Forward
0 new messages