473,398 Members | 2,188 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Controlling XY position of printer output

Please excuse my cluelessness on the subject - this is the first time I've worked with printing in VB (and it may be the last) and the more I work with it, the more confused I become...

First, I'm setting the printer's scale and the X,Y position of the output:

Expand|Select|Wrap|Line Numbers
  1. Sub SetLargePrinterScale(obj As Object, VertPosition As Single)
  2. Dim Owid As Single
  3. Dim Ohgt As Single
  4. Dim Pwid As Single
  5. Dim Phgt As Single
  6. Dim Xmid As Single
  7. Dim Ymid As Single
  8. Dim S As Single
  9. Dim ScaleFactor As Single
  10.  
  11.     ScaleFactor = (50 - frmPrint.Slider3.Value) / 10
  12.  
  13.     Owid = obj.ScaleX(obj.ScaleWidth, obj.ScaleMode, vbPixels)
  14.     Ohgt = obj.ScaleY(obj.ScaleHeight, obj.ScaleMode, vbPixels)
  15.  
  16.     Pwid = Printer.ScaleX(Printer.ScaleWidth, Printer.ScaleMode, vbPixels)
  17.     Phgt = Printer.ScaleY(Printer.ScaleHeight, Printer.ScaleMode, vbPixels)
  18.  
  19.     ' This determines which dimension (X or Y) is largest, so I can make sure neither
  20.     ' dimension exceeds the printer width
  21.     If Ohgt / Owid > Phgt / Pwid Then
  22.         S = Phgt / Ohgt
  23.     Else
  24.         S = Pwid / Owid
  25.     End If
  26.  
  27.     Pwid = obj.ScaleX(Pwid * ScaleFactor, vbPixels, obj.ScaleMode) / S
  28.     Phgt = obj.ScaleY(Phgt * ScaleFactor, vbPixels, obj.ScaleMode) / S
  29.  
  30.     ' This sets the vertical and horizontal coordinates of the center of the image
  31.     ' Using the settings below, the image is printed in the center of the page
  32.     Xmid = (obj.ScaleLeft + obj.ScaleWidth / 2) * ScaleFactor
  33.     Ymid = (obj.ScaleTop + obj.ScaleHeight / 1.6) * ScaleFactor
  34.  
  35.     Printer.Scale (Xmid - Pwid / 2, Ymid - Phgt / 2)-(Xmid + Pwid / 2, Ymid + Phgt / 2)
  36.  
  37. End Sub
This prints the image in the center of the page.

Then I print a spyrograph-style pattern:

Expand|Select|Wrap|Line Numbers
  1. Sub PrintRoullette()
  2. Dim pi, r, R1, R2, i
  3.  
  4.     For i = 0 To UBound(prtR1) - 1
  5.  
  6.         R1 = prtR1(i)
  7.         R2 = prtR2(i)
  8.         r = prtR(i)
  9.  
  10.         pi = 4 * Atn(1)
  11.  
  12.         't represents time, X & Y are the coordinates of each point drawn
  13.         Dim Loop1, Loop2
  14.         Dim t, X, Y As Double
  15.         Dim Rotations As Integer
  16.  
  17.         If Int(R1 / R2) = R1 / R2 Then
  18.             Rotations = 1
  19.         Else
  20.             Rotations = Abs(R2 / 10)
  21.             If Int(R2 / 10) <> R2 / 10 Then Rotations = 10 * Rotations
  22.         End If
  23.         Rotations = Rotations + 1
  24.  
  25.         For Loop1 = 1 To Rotations
  26.  
  27.             For Loop2 = 0 To 2 * pi Step pi / (4 * 360)
  28.                 t = Loop1 * 2 * pi + Loop2
  29.                 X = (R1 + R2) * Cos(t) - (R2 + r) * Cos(((R1 + R2) / R2) * t)
  30.                 Y = (R1 + R2) * Sin(t) - (R2 + r) * Sin(((R1 + R2) / R2) * t)
  31.                 Printer.PSet (Printer.ScaleWidth / 2 + X, Printer.ScaleHeight _
  32.                   / 2 + Y), prtPen(i)
  33.             Next
  34.             DoEvents
  35.         Next
  36.     Next
  37.  
  38. End Sub
Then I issue a Printer.EndDoc command to end the job and send it to the printer.

I've tried adding pixels to the Printer.Scale statement in the SetLargePrinterScale sub:

Expand|Select|Wrap|Line Numbers
  1. Printer.Scale (Xmid - (Pwid / 2) + 300, Ymid - (Phgt / 2) + 300)-(Xmid + (Pwid / 2) + 300, Ymid + (Phgt / 2) + 300)
The printer's resolution is 300dpi, so I would expect this change to move image down and right by 1 inch - instead it moves it up and left by about 2.5 inches - I get more confused every time I print...

joe
Feb 13 '07 #1
2 5706
Killer42
8,435 Expert 8TB
To move the X/Y position, you probably need to adjust CurrentX/CurrentY, rather than adjust the scale.
Feb 13 '07 #2
Tried that - it works with text, but I'm using PSet() to print, so it has no effect.

joe
Feb 13 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Richard Johnson | last post by:
I am a C++ newbie and am trying to send simple text data to my local printer. My printer is a USB printer and I have tried the following code using my USB port. This code executes but does not send...
2
by: Stefan | last post by:
Hi NG How can I control the default printer in c#?
1
by: Karthic | last post by:
When i right click on the .rpt file in the VS 2003, i see a property printer setting. It says "No printer" on the top and there is option to select printer and paper settings etc.. I want to...
6
by: Ioannis Demetriades | last post by:
Hi, I need to change the printer's font to "control" -a printer font, and then send a sequence of characters to the printer. My problem is that I cannot change the printer's font. Can this be...
2
by: Wouter van Teijlingen | last post by:
Dear Readers, I was reading about how to control the COM and LPT port using VB .NET. I've found a lot of information, and it was very useful to me. I found an example program on the site of...
2
by: dever | last post by:
I checked my color printers's Printersettings.SupportsColor, which all showed false. What is wrong that I could not use this property. Also, what other way to detect if a printer is color...
1
by: Mario Figueiredo | last post by:
Hello everyone, I'm having trouble controlling the cursor position when I make two consecutive calls to the get family of functions. This problem does not happen if there is an output in...
3
by: Jason | last post by:
Matt suggests: <BODY onload="window.scrollTo(x,y)"> However I am linking to Google Images so I can't modify their page code. Is there a way to link from frame a to frame b so that the...
9
by: id10t error | last post by:
Hello, I am going to be using a Symbol WT4090 to scan items. I need to printer a tag from the Zebra ql320 plus. I am trying to do this is Visual basic 2005. Does anyone know and good site to...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.