It prints skewed

I am trying to print a canvas and, with the following code, it prints but it appears stretched in height (it prints in A4 sheet):

[code] dim page as Graphics

	Dim ps As New PrinterSetup //Settaggio dei parametri di stampa
	Dim mPrinterSettings as String
	
	
	If ps.PageSetupDialog Then
			mPrinterSettings = ps.SetupString
	End If
	
	page = OpenPrinterDialog(ps)
	
	 if page<>nil then
			    dim p as new Picture( Vettori.Width, TriVen.Height, 32)
			  Vettori.DrawInto (p.Graphics, 0, 0)
			    dim gheight as Integer = page.Width/page.Width*p.Height
			    
			   page.DrawPicture( p, 0, 0, page.Width, p.Height, 0, 0, p.Width, p.Height)
	  end if [/code]

I’m having problems in fitting a canvas (or a window) into a sheet (be it a paper or PDF). They get cropped or skewed.
Could you point me in the right direction?

page.DrawPicture( p, 0, 0, page.Width, p.Height, 0, 0, p.Width, p.Height)

if the ration between PAGE and P are not the same it will be “resized”

you need to calculate a new “W” and “H” value instead of using page.Width and Page.Height
in order to maintain the aspect ratio of the original picture

off the top of my head

w=page.width
h=page.height
if p.width>p.height then 
h=h*(p.height/p.width)
end if
if p.height>p.width then 
w=w*(p.width/p.height)
end if

page.drawpicture p,0,0,w,h, 0,0,p.width,p.height

I MAY have gotten the calculation reversed…