Results 1 to 3 of 3

Thread: Print a file? send file to printer....

  1. #1

    Thread Starter
    Addicted Member coolwater's Avatar
    Join Date
    Dec 2004
    Location
    philippines
    Posts
    215

    Resolved Print a file? send file to printer....

    i have this wierd ms access project. The project is about retrieving .tif files from a database (stored path of .tif files) and present it for viewing in a imagebox. My problem is how to print the retrieved .tif file. We are not allowed to use a print common dialoge box. a click of a button is all that's needed to print the .tif file. Is there a way to print/send the .tif file to printer? Do I have to deal with the printer collection? Is this possible? (locate the file from the hard drive then send printer?)
    Last edited by coolwater; Sep 15th, 2005 at 01:37 PM. Reason: solved

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Print a file? send file to printer....

    Change from using an Image control to using a Picturebox and use this to send the picture to print.
    VB Code:
    1. Private Sub PrintPictureToFitPage(Prn As Printer, Pic As Picture)
    2.  
    3. Dim PicRatio     As Double
    4. Dim PrnWidth     As Double
    5. Dim PrnHeight    As Double
    6. Dim PrnRatio     As Double
    7. Dim PrnPicWidth  As Double
    8. Dim PrnPicHeight As Double
    9. Const vbHiMetric As Integer = 8 '
    10. ' Determine if picture should be printed in landscape
    11. ' or portrait and set the orientation.'
    12. If Pic.Height >= Pic.Width Then
    13.     Prn.Orientation = vbPRORPortrait   'Taller than wide
    14. Else
    15.     Prn.Orientation = vbPRORLandscape  'Wider than tall
    16. End If '
    17. ' Calculate device independent Width to Height ratio for picture.'
    18. PicRatio = Pic.Width / Pic.Height '
    19. ' Calculate the dimentions of the printable area in HiMetric.'
    20. With Prn
    21.     PrnWidth = .ScaleX(.ScaleWidth, .ScaleMode, vbHiMetric)
    22.     PrnHeight = .ScaleY(.ScaleHeight, .ScaleMode, vbHiMetric)
    23. End With '
    24. ' Calculate device independent Width to Height ratio for printer.'
    25. PrnRatio = PrnWidth / PrnHeight '
    26. ' Scale the output to the printable area.'
    27. If PicRatio >= PrnRatio Then    '
    28.     ' Scale picture to fit full width of printable area.    '
    29.     PrnPicWidth = Prn.ScaleX(PrnWidth, vbHiMetric, Prn.ScaleMode)
    30.     PrnPicHeight = Prn.ScaleY(PrnWidth / PicRatio, vbHiMetric, Prn.ScaleMode)
    31. Else
    32.     ' Scale picture to fit full height of printable area.    '
    33.     PrnPicHeight = Prn.ScaleY(PrnHeight, vbHiMetric, Prn.ScaleMode)
    34.     PrnPicWidth = Prn.ScaleX(PrnHeight * PicRatio, vbHiMetric, Prn.ScaleMode)
    35. End If '
    36. ' Print the picture using the PaintPicture method.'
    37. Call Prn.PaintPicture(Pic, 0, 0, PrnPicWidth, PrnPicHeight)
    38. End Sub
    39.  
    40. Private Sub cmdPrintPicture_Click()  
    41. Call PrintPictureToFitPage(Printer, Picture1.Picture)
    42. Printer.EndDoc
    43. End Sub

  3. #3

    Thread Starter
    Addicted Member coolwater's Avatar
    Join Date
    Dec 2004
    Location
    philippines
    Posts
    215

    Re: Print a file? send file to printer....

    thank you very much for this. i will apply this to vb coz i cant find the picture box control in access. thanks a lot.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width