Results 1 to 4 of 4

Thread: Formatting Output When Printing Images

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Aug 2000
    Location
    Charleston, S.C.
    Posts
    21
    Is there any way to tell the printer object to print the image in the middle of the page, instead of the default of printing the image in the top left corner of the page?

    Thanks.

  2. #2
    Hyperactive Member
    Join Date
    Jun 2000
    Location
    Auckland, NZ
    Posts
    411

    currentX and currentY

    Or so I believe..

    Paul Lewis

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Aug 2000
    Location
    Charleston, S.C.
    Posts
    21

    Still having problems with centering image

    Thanks for the info Paul. Now I can almost get the image centered on the page with

    Private Sub mnuPrint_Click()

    Picture1.CurrentX = ((Printer.ScaleWidth / 2) - (Picture1.Width / 2))
    Picture1.CurrentY = ((Printer.ScaleHeight / 2) - (Picture1.Height / 2))

    Printer.PaintPicture Picture1, Picture1.CurrentX, Picture1.CurrentY
    Printer.EndDoc

    End Sub

    But there is still some very noticeable "off-centeredness" of the image. What I was attempting to do was change the current x to shift left half of the image width and the current y to shift upward half of the image height to center it on the page.
    Is there some other attribute that I could use? as I am trying to make the image "auto-centerable" regardless of the image size. If it came down to it, I guess I could hard code the values into to print method as all of the images would be of the same size, but figured that I would try to make the mnuPrint_Click () function as widely applicable as possible.

  4. #4
    Hyperactive Member
    Join Date
    Jun 2000
    Location
    Auckland, NZ
    Posts
    411

    No ideas sorry

    I only mentioned the currentX and currentY because I had seen them referred to in other posts.

    What scalemode is the printer object set to in your example?

    The code I worte below and the code you wrote both produce the same output on my printer here.

    The printer here is a laser printer (600dpi) but I guess the only things that would cause it to be off centre for you are:
    Something screwy in the printer driver
    OR The bitmap has a border on one or two sides that you cannot see in the printout (but you would see on the screen so it probably isn't that)
    OR The printer has a low resolution so rounding causes the image to be slightly off (we're talking millimeters here though).


    Code:
    Private Sub Command1_Click()
      Form1.ScaleMode = Printer.ScaleMode
      Dim x, y As Single
      x = Printer.ScaleWidth / 2 - Picture1.Width / 2
      y = Printer.ScaleHeight / 2 - Picture1.Height / 2
      Picture1.Move x, y
      Printer.PaintPicture Picture1.Picture, x, y
      Printer.EndDoc
    End Sub
    Sorry I can't be more authoritative on the subject.

    Regards
    Paul Lewis

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