Private Sub Button1_Click
	For Each Counts As View In Root.GetAllViewsRecursive
		Log(Counts.Tag)
Try
		If Counts Is Panel Then 'It works.
			Log("Pane Name  "& Counts.Tag)
			If Counts.Tag = "installPanel" Then
'				NNode.Initialize("")
				
				Dim NNode As View = Counts
				
			End If
		End If
Catch
			Log(LastException)
		End Try
	Next
	PanelToPdf(NNode, "12test.pdf")


	
End Sub

Private Sub PanelToPdf(Panel As B4XView, FileName As String)
	Dim pdf As PdfDocument
	pdf.Initialize
	pdf.StartPage(595, 842) 'A4 size
	Dim bmp As B4XBitmap = Panel.Snapshot
	Dim dest As Rect
	dest.Initialize(10, 10, 0, 0)
	dest.Width = bmp.Width / bmp.Scale
	dest.Height = bmp.Height / bmp.Scale
	pdf.Canvas.DrawBitmap(bmp, Null, dest)
	pdf.FinishPage

	Dim out As OutputStream = File.OpenOutput(File.DirInternal, FileName, False)
	pdf.WriteToStream(out)
	out.Close
	pdf.Close
	
	Dim iprint As Printer
	iprint.Initialize("")
	iprint.PrintPdf("iprint",File.DirInternal, FileName)

End Sub
