Printing mystery

I am encountering a difficulty with printing.

I create the print graphics object with http://documentation.xojo.com/index.php/OpenPrinterDialog as I always did.

The difference is I created a global g as graphics property, so I can pass all requests to a generalized routine which fetches a print queue.

It hangs and never prints.

I verified g is not nil.

What may be going on ?

TIA

Michel, can you post a snippet or two?
I do something similar and have had no problems (but its been a version of two)

[code] if pageSetup = nil then
pageSetup = New PrinterSetup

If pageSetup.PageSetupDialog Then
  system.DebugLog "page setup dialog"
  printerSetupString = pageSetup.SetupString
End If

pageSetup.MaxHorizontalResolution=-1
pageSetup.MaxVerticalResolution=-1

if pagesetup.HorizontalResolution = 72 then 
  beep
  return
end if

if pagesetup.HorizontalResolution <> 300 then
  pRatio = pageSetup.HorizontalResolution/72
  zRatio = 0.6666666666*pRatio
end if

end if

g = OpenPrinterDialog(pageSetup)

g.textsize = 24zRatio
g.DrawString(“Hello World”, 100, 500
zRatio)[/code]

g is a graphics global module property

If I dim it locally, it prints.

assumption :
somewhere you have a public

DIM g as GRAPHICS (or equiv)

But Michel… WHERE do you tell it to PRINT the page… you put “Hello World”, and now it is waiting for either more drawing instructions, or to eject/print the page

g.NextPage
or
g=nil

Yeah !

This is one of those moments when asking the question brings the response : when I dim g becomes nil at the end of the event, and the page is sent to the printer.

With a property that does not happen, I have to set it myself to nil.

That is what actually prints.

Thanks

Right… it would become nil when it went out of scope… but in your case it never does :slight_smile: