Skip to main content

AccessTr.neT


A4 Sayfaya Tam Olarak Yazdırmak

A4 Sayfaya Tam Olarak Yazdırmak

#2
Çözümü buldum. Başka arkadaşlara lazım olur diye burada paylaşıyorum. Buyrun.


Option Explicit

' Print the PictureBox's picture as large as
' possible and centered. Then draw a box around it.
Private Sub cmdPrint_Click()
Dim picture_aspect As Single
Dim printer_aspect As Single
Dim wid As Single
Dim hgt As Single
Dim X As Single
Dim Y As Single

   ' Set the PictureBox's ScaleMode to pixels to
   ' make things interesting.
   picCanvas.ScaleMode = vbPixels

   ' Compare the picture's and Printer's
   ' aspect ratios.
   picture_aspect = picCanvas.ScaleHeight / picCanvas.ScaleWidth
   printer_aspect = Printer.ScaleHeight / Printer.ScaleWidth
   If picture_aspect > printer_aspect Then
       ' The picture is too tall and thin.
       ' Print it as tall as possible.
       hgt = Printer.ScaleHeight
       wid = hgt / picture_aspect
   Else
       ' The picture is too short and wide.
       ' Print it as wide as possible.
       wid = Printer.ScaleWidth
       hgt = wid * picture_aspect
   End If

   ' See where we need to place the picture
   ' to center it.
   X = Printer.ScaleLeft + (Printer.ScaleWidth - wid) / 2
   Y = Printer.ScaleTop + (Printer.ScaleHeight - hgt) / 2

   ' Print the picture.
   Printer.PaintPicture picCanvas.Picture, X, Y, wid, hgt

   ' Draw the box.
   Printer.Line (X, Y)-Step(wid, hgt), , B

   ' Finish printing.
   Printer.EndDoc

   MsgBox "Done"
End Sub
Private Sub Form_Load()
Const SAMPLE_TEXT As String = "Geodesic Sphere"

   ' Draw on the picture.
   picCanvas.Font.Name = "Times New Roman"
   picCanvas.Font.Size = 24
   picCanvas.Font.Bold = True
   picCanvas.ForeColor = vbBlack

   ' Center the text horizontally at the top
   ' of the picture.
   picCanvas.CurrentX = (picCanvas.ScaleWidth - picCanvas.TextWidth(SAMPLE_TEXT)) / 2
   picCanvas.CurrentY = 0

   picCanvas.AutoRedraw = True
   picCanvas.Print SAMPLE_TEXT

   ' Make the text a permanent part of the image.
   ' This is important if you later need to copy
   ' the picture to another control or the Printer.
   picCanvas.Picture = picCanvas.Image
End Sub
Cevapla

Bir hesap oluşturun veya yorum yapmak için giriş yapın

Yorum yapmak için üye olmanız gerekiyor

ya da

Bu Konudaki Yorumlar
Cvp: A4 Sayfaya Tam Olarak Yazdırmak - Yazar: Uğur ŞİRİN - 09/06/2017, 01:43
Task