\mode<handout>
{\setbeamercolor{background canvas}{bg=black!3}
	\usepackage{pgf}
	\usepackage{pgfpages}
	
	\pgfpagesdeclarelayout{2 on 1 boxed with notes}
	{
		\edef\pgfpageoptionheight{\the\paperheight} 
		\edef\pgfpageoptionwidth{\the\paperwidth}
		\edef\pgfpageoptionborder{0pt}
	}
	{
		\setkeys{pgfpagesuselayoutoption}{landscape}
		\pgfpagesphysicalpageoptions
		{%
			logical pages=4,%
			physical height=\pgfpageoptionheight,%
			physical width=\pgfpageoptionwidth,%
			last logical shipout=2%
		}
		\pgfpageslogicalpageoptions{1}
		{%
			border code=\pgfsetlinewidth{1pt}\pgfstroke,%
			scale=1,
			center=\pgfpoint{.25\pgfphysicalwidth}{.75\pgfphysicalheight}%
		}%
		\pgfpageslogicalpageoptions{2}
		{%
			border code=\pgfsetlinewidth{1pt}\pgfstroke,%
			scale=1,
			center=\pgfpoint{.25\pgfphysicalwidth}{.25\pgfphysicalheight}%
		}%
		\pgfpageslogicalpageoptions{3}
		{%
			border shrink=\pgfpageoptionborder,%
			resized width=.7\pgfphysicalwidth,%
			resized height=.5\pgfphysicalheight,%
			center=\pgfpoint{.75\pgfphysicalwidth}{.29\pgfphysicalheight},%
			copy from=3
		}%
		\pgfpageslogicalpageoptions{4}
		{%
			border shrink=\pgfpageoptionborder,%
			resized width=.7\pgfphysicalwidth,%
			resized height=.5\pgfphysicalheight,%
			center=\pgfpoint{.75\pgfphysicalwidth}{.79\pgfphysicalheight},%
			copy from=4
		}%
		
		\AtBeginDocument
		{
			\newbox\notesbox
			\setbox\notesbox=\vbox
			{
				\hsize=\paperwidth
				\vskip-1in\hskip-1in\vbox
				{
					\vskip1cm
					Notes\vskip1cm
					\hrule width\paperwidth\vskip1cm
					\hrule width\paperwidth\vskip1cm
					\hrule width\paperwidth\vskip1cm
					\hrule width\paperwidth\vskip1cm
					\hrule width\paperwidth\vskip1cm
					\hrule width\paperwidth\vskip1cm
					\hrule width\paperwidth\vskip1cm
					\hrule width\paperwidth\vskip1cm
					\hrule width\paperwidth
				}
			}
			\pgfpagesshipoutlogicalpage{3}\copy\notesbox
			\pgfpagesshipoutlogicalpage{4}\copy\notesbox
		}
	}
\pgfpagesuselayout{2 on 1 boxed with notes}[a4paper,border shrink=5mm]
}