# printpreview in a dialog

**URL:** <https://forum.servoy.com/t/printpreview-in-a-dialog/10508>\
**Category:** Classic Servoy\
**Created:** [April 6, 2009, 9:05am UTC](https://forum.servoy.com/t/printpreview-in-a-dialog/10508 "2009-04-06T09:05:46Z")\
**Posts on this page:** 1\
**Page:** 1

<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 6, 2009, 9:05am UTC](https://forum.servoy.com/t/printpreview-in-a-dialog/10508/1 "2009-04-06T09:05:46Z")

</div>

To get printpreview in a dialog, two global methods are needed:

```auto
function printPreviewInDialog(formName)
{
	if (application.getApplicationType() == 2) //webclient print == pdf is always opened separate tab/window by browser anyway
	{
		globals.startinprintpreview = formName
		application.showFormInDialog( forms[formName], -1, -1, -1, -1, "PRINT_TEST", true, false, "printing", true)
	}
	else
	{
		globals.startinprintpreview = null
		forms[formName].controller.showPrintPreview( true)
	}
}

function checkForPrintPreview()
{
	if (globals.startinprintpreview == currentcontroller.getName())
	{
		currentcontroller.showPrintPreview( true)
		globals.startinprintpreview = 'close_printpreview'
	}
	else if (globals.startinprintpreview == 'close_printpreview')
	{
		if (application.getApplicationType() == 2) 
		{
			application.closeFormDialog("printing")
		}
	}
}

```

If you want to show a printpreview in a dialog call for example: printPreviewInDialog(‘customer’) //customers is form name  
In the forms you ever might want to show in printpreview, do in the onShow event a call to checkForPrintPreview()
