>Tengo en un form, un picture que ocupa todo el form y quisiera imprimirlo.
>Quisiera contemplar la posibilidad que si el bitmap es mas grande que el
>picture, poder imprimirlo, en una sola hoja(comprimirlo para que entre
>automaticamente)
Prueba con esto que acabo de hacer. No lo he probado mucho pero creo que
funciona.
Sub ImprimeMaxPicture(Imagen As IPictureDisp, Optional CentrarH As Boolean
= True, Optional CentrarV As Boolean = True, Optional orientacion As Long = 1)
'Imprime una imagen en la impresora comprimiéndola para que quepa en una
'hoja. Si su tamaño es menor que el de la hoja, no se modifica.
'Parametros:
' Imagen : la propiedad picture del picture o form que queramos imprimir
' CentrarH : si true la imagen se imprime centrada horizontalmente
' CentrarV : si true la imagen se imprimir centrada verticalmente
' Orientacion : 1 = Vertical
' 2 = Horizontal
' 0 = Automática en función de las proporciones de la foto
' si es más ancha que el papel
Dim TamañoX As Single, TamañoY As Single, PosX As Single, PosY As Single
Dim Relacion As Single
'ajusto la orientación de la impresora
Select Case orientacion
Case 1: Printer.Orientation = vbPRORPortrait
Case 2: Printer.Orientation = vbPRORLandscape
Case 0:
If (Imagen.Width > Imagen.Height) And (Imagen.Width >
Printer.ScaleWidth) Then
Printer.Orientation = vbPRORLandscape
Else
Printer.Orientation = vbPRORPortrait
End If
End Select
'hallo la relación entre el ancho y el alto de la imagen
Relacion = Imagen.Width / Imagen.Height
TamañoX = Imagen.Width: TamañoY = Imagen.Height
'ajusto el tamaño a imprimir a los márgenes de la impresora
If TamañoX > Printer.ScaleWidth Then
TamañoX = Printer.ScaleWidth
TamañoY = TamañoX / Relacion
End If
If TamañoY > Printer.ScaleHeight Then
TamañoY = Printer.ScaleHeight
TamañoX = TamañoY * Relacion
End If
PosX = 0: PosY = 0
'hallo la posición de impresión
If CentrarH Then PosX = (Printer.ScaleWidth - TamañoX) / 2
If CentrarV Then PosY = (Printer.ScaleHeight - TamañoY) / 2
Printer.PaintPicture Imagen, PosX, PosY, TamañoX, TamañoY
Printer.EndDoc
End Sub
Un saludo.
_________________________________________________
José Rubí de la Vega
E-mail : jrubi@arrakis.es
WWW : http://www.arrakis.es/~jrubi
Podrás encontrar información sobre VB, la lista
VB-ESP y un resumen de los mensajes de la misma