# Display a report in a canvas

**URL:** <https://forum.xojo.com/t/display-a-report-in-a-canvas/13932>\
**Category:** Getting Started\
**Created:** [January 27, 2014, 10:26pm UTC](https://forum.xojo.com/t/display-a-report-in-a-canvas/13932 "2014-01-27T22:26:55Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_Schmoyer](https://forum.xojo.com/letter_avatar_proxy/v4/letter/j/b9bd4f/32.png) [@John\_Schmoyer](https://forum.xojo.com/u/John_Schmoyer)\
**Post date:** [January 27, 2014, 10:26pm UTC](https://forum.xojo.com/t/display-a-report-in-a-canvas/13932/1 "2014-01-27T22:26:55Z")

</div>

Hi. I have a program that prints a report to a printer. The report is created in code using a graphics object: GrObject = OpenPrinterDialog(PgSetup). This is working very well. Now I want to output the report to the screen (print preview), so I created a window with a canvas control on it. But a canvas wants a picture object, not a graphics object. What is the best way to get my report onto the canvas? This report is only one page so I am not concerning myself with page breaks at this time. I tried canvas.drawinto(GrObject, 0, 0) but nothing is painted.

---

<div class="post-metadata">

**Author:** ![Norman\_P](https://forum.xojo.com/letter_avatar_proxy/v4/letter/n/858c86/32.png) [@Norman\_P](https://forum.xojo.com/u/Norman_P)\
**Post date:** [January 27, 2014, 11:58pm UTC](https://forum.xojo.com/t/display-a-report-in-a-canvas/13932/2 "2014-01-27T23:58:01Z")

</div>

create a picture pass its graphics object to your report printing code then put the picture on the canvas

---

<div class="post-metadata">

**Author:** ![John\_Schmoyer](https://forum.xojo.com/letter_avatar_proxy/v4/letter/j/b9bd4f/32.png) [@John\_Schmoyer](https://forum.xojo.com/u/John_Schmoyer)\
**Post date:** [January 28, 2014, 12:58am UTC](https://forum.xojo.com/t/display-a-report-in-a-canvas/13932/3 "2014-01-28T00:58:11Z")

</div>

Thanks for the tip Norman. In my print class I have two properties, GrObject as Graphics and GrPicture as Picture. In my open printer routine I have:

` if ToScreen = True then
    GrPicture = New Picture(3900,5100,16)
    GrObject = GrPicture.Graphics`

I then do the printing to the GrObject and pass it to the canvas which is on a new window:

` dim pp as New PreviewWindow
  pp.Canvas1.Refresh()
  `

The paint event:

```auto
g = GrPicture.Graphics
```

My canvas is blank though, so I must still be missing something.

---

<div class="post-metadata">

**Author:** ![Tim\_Hare](https://forum.xojo.com/user_avatar/forum.xojo.com/tim_hare/32/176_2.png) [@Tim\_Hare](https://forum.xojo.com/u/Tim_Hare)\
**Post date:** [January 28, 2014, 1:25am UTC](https://forum.xojo.com/t/display-a-report-in-a-canvas/13932/4 "2014-01-28T01:25:18Z")

</div>

The paint event should be

```auto
g.DrawPicture GrPicture, 0, 0
```

---

<div class="post-metadata">

**Author:** ![John\_Schmoyer](https://forum.xojo.com/letter_avatar_proxy/v4/letter/j/b9bd4f/32.png) [@John\_Schmoyer](https://forum.xojo.com/u/John_Schmoyer)\
**Post date:** [January 28, 2014, 1:58am UTC](https://forum.xojo.com/t/display-a-report-in-a-canvas/13932/5 "2014-01-28T01:58:37Z")

</div>

Thanks Tim! That did the trick.

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [October 29, 2020, 5:03pm UTC](https://forum.xojo.com/t/display-a-report-in-a-canvas/13932/6 "2020-10-29T17:03:18Z")

</div>


