Draw to Canvas - Preview differs from print output

Hi,

I am drawing a report to a canvas to get a print preview. When displayed, the page on the canvas differs from the one I get when I print to PDF Preview(Mac OS Preview) or the real printer. The left and top margin are to small(actually almost 0).

This is how I generate my picture do draw on the canvas;

ps = new PrinterSetup
ps.MaxHorizontalResolution = -1
ps.MaxVerticalResolution = -1 // gets me the max. Printer Resolution --> needs to be scaled in the report

  if ps.PageSetupDialog then
    thePS = ps 
  else
    return
  end if

gPict = new picture(ThePS.pageWidth, ThePS.pageHeight, 32)
myReport(gPict.Graphics,ThePS,0)

In my report I scale the resolution recieved from the printer to display the report;

  xScaleFactor = ThePS.HorizontalResolution / 72.0
  yScaleFactor = ThePS.VerticalResolution / 72.0

I then build my report with the information from “ThePS”

ThePS.Left for the left margin
ThePS.Top for the top margin

The output in the canvas seems to miss the first lines. Left and top margin are actually 0 (zero) on the canvas.
In the printed report they are as specified by the printer settings.

What am I missing ? Any ideas ? How do you generate a print preview and how do you scale the printer resolution ?
Thanks in advance,
wop

The drawing area of a canvas, and this includes a “printer” always starts at 0,0…
If you set margins in the printer itself, then all you are doing is moving 0,0 in relation to the edge of the paper and making the drawing area that much smaller

Also the resolution on the screen is not the same as the resolution of your printer, so yes the printer will look different (hopefully better) that your screen

Thanks Dave !

By settings the left margin and the top margin manually to e.g. “25” i managed to get the same output on screen (screen resolution) and printout (300dpi). And both of them look good. Even if the screen output is scaled e.g. by 200%.

The only problem that remains is to read the margin which is displayed in the PagesetupDialog. Maybe I can get the info by using the MBS Plugins… Will see.

You can figure this out from the PrinterSetup object.

Width = printable area
PageWidth = the width of the whole page
PageLeft is the offset from the left edge of the paper

From these, you can figure out the right margin