Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Printed Page Margins - revisited

Posted on 1998-08-13
3
207 Views
Last Modified: 2010-04-30
My application produces a printed page output. The printing is complicated, some graphics, some text. When run on various systems, sometimes the printing overshoots the margins, usually the bottom one, yielding partial printout on multiple pages.

I started with guessing that any printer could handle half inch margins. 8.5 X 11 inches is 12240 X 15840 twips. Taking 1/2 inch off (720 twips) all around gives a printing "real estate" of 10800 X 14400 twips with upper right hand corner at x=720 and y=720 twips.

Printing is scaled to fit in the 10800 X 14400 box.

I found that I had to back off, that some installations evidently had bigger margins than that.  I backed off by guessing 100 twips at a time. There has to be a more direct way to do this.

How can I use PaperSize, Height, Width, ScaleLeft, ScaleTop properties of the printer object to get "usable twip real estate" information (from the specific installation) into my source code?  If I could do that, I could take it from there. -- Norm
0
Comment
Question by:normpos
  • 2
3 Comments
 
LVL 8

Accepted Solution

by:
mrmick earned 100 total points
ID: 1468781
  Dim PageWidthPixels As Long, PageHeightPixels As Long
   Dim UnPrintableAreaX As Long, UnPrintableAreaY As Long
   Dim PrintablePixelsX As Long, PrintablePixelsY As Long

   PageWidthPixels = Int(Printer.Width / Printer.TwipsPerPixelX)
   PageHeightPixels = Int(Printer.Height / Printer.TwipsPerPixelY)
   UnPrintableAreaX = PageWidthPixels - Int(Printer.ScaleWidth / Printer.TwipsPerPixelX)
   UnPrintableAreaY = PageHeightPixels - Int(Printer.ScaleHeight / Printer.TwipsPerPixelY)
   PrintablePixelsX = PageWidthPixels - UnPrintableAreaX
   PrintablePixelsY = PageHeightPixels - UnPrintableAreaY

0
 
LVL 8

Expert Comment

by:mrmick
ID: 1468782
whoops... place this just after the sample above in a procedure and call it to see the result.


   MsgBox "PageWidthPixels: " & PageWidthPixels & vbCrLf _
          & "PageHeightPixels: " & PageHeightPixels & vbCrLf _
          & "UnPrintableAreaX: " & UnPrintableAreaX & vbCrLf _
          & "UnPrintableAreaY: " & UnPrintableAreaY & vbCrLf _
          & "PrintablePixelsX: " & PrintablePixelsX & vbCrLf _
          & "PrintablePixelsY: " & PrintablePixelsY & vbCrLf
         

0
 

Author Comment

by:normpos
ID: 1468783
mrmick: Thank you! Please be available if I have further comments on this. I'll get back to you and let you know how it works. -- Norm
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

837 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question