# Documentation: Code sample for showPrintPreview()

**URL:** <https://forum.servoy.com/t/documentation-code-sample-for-showprintpreview/4043>\
**Category:** Classic Servoy\
**Created:** [April 14, 2005, 1:23pm UTC](https://forum.servoy.com/t/documentation-code-sample-for-showprintpreview/4043 "2005-04-14T13:23:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![swingman](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/swingman/32/4536_2.png) [@swingman](https://forum.servoy.com/u/swingman)\
**Post date:** [April 14, 2005, 1:23pm UTC](https://forum.servoy.com/t/documentation-code-sample-for-showprintpreview/4043/1 "2005-04-14T13:23:42Z")

</div>

> //Show this form in print preview  
> controller.showPrintPreview();  
> //to print current record only  
> [//controller.showPrintPreview](https://controller.showPrintPreview)(true);

It would be useful to mention in the code sample that you have to create an “onClose” method for the form to close the print preview.  
I can see from the forum I’m not the only one who has wondered why the “close” button does not ‘work’.

---

<div class="post-metadata">

**Author:** ![Jan\_Blok](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@Jan\_Blok](https://forum.servoy.com/u/Jan_Blok)\
**Post date:** [April 20, 2005, 12:48pm UTC](https://forum.servoy.com/t/documentation-code-sample-for-showprintpreview/4043/2 "2005-04-20T12:48:50Z")

</div>

The close button should always work, and there is no need for a method called “onClose”, can you reproduce this behaviour in a small smaple solution?

---

<div class="post-metadata">

**Author:** ![swingman](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/swingman/32/4536_2.png) [@swingman](https://forum.servoy.com/u/swingman)\
**Post date:** [April 20, 2005, 8:04pm UTC](https://forum.servoy.com/t/documentation-code-sample-for-showprintpreview/4043/3 "2005-04-20T20:04:36Z")

</div>

I have since upgraded from 2.2rc3 to 2.2rc5 and it is now working fine without the onClose method.
