Author Topic: Printing from the plot screen  (Read 6884 times)

daisearle

  • Registered User
  • *
  • Posts: 4
    • View Profile
Printing from the plot screen
« on: 07-Nov-2006, 17:29:19 »
I have just installed spine 3.7 on a windows 98 L2 machine. The text listing of NOTAMS works fine on both printers I have attached to the computer. I have a Laserjet 4L, and an Epson Stylus Color 860. However the plot screen only prints the base information with no NOTAM data on the Laserjet, and prints nothing at all on the Epson (I particularly wanted to print in colour). If I examine the printer status dialog there is no document listed, when I try to use the Epson. I haven't looked at the dialog when using the Laserjet, as it actually printed something. It doesn't matter whether I select the printer to use via the printers dialog, or set either one as the Windows default printer.

Any ideas, or workarounds?

jeff

  • Administrator
  • Registered User
  • *****
  • Posts: 176
    • View Profile
    • Jeff Goodenough's Pages
Printing from the plot screen
« Reply #1 on: 07-Nov-2006, 20:03:36 »
This is strange. Printing the plot screen is a standard Microsoft function without any special programming in the Spine software.

Can you successfully print in colour from other graphic programs, such as MSPaint?

daisearle

  • Registered User
  • *
  • Posts: 4
    • View Profile
Printing from the plot screen
« Reply #2 on: 08-Nov-2006, 16:47:29 »
no problems with any other colour graphics printing program over two or three years! I have double checked, MsPaint still works!

Is there a problem with initialisation of the printer object? I used to write some fairly exacting graphic software in Delphi, where initialisation of the chosen printer scaling required some inelegant workarounds, allegedly because of Microsoft standard calls not correctly returning all the properties expected.

jeff

  • Administrator
  • Registered User
  • *****
  • Posts: 176
    • View Profile
    • Jeff Goodenough's Pages
Printing from the plot screen
« Reply #3 on: 08-Nov-2006, 17:14:04 »
I use an HP 960C with no problems, and you are the first to report any. Are you familiar with Visual C++ at all? I use MFC, and the only thing to do with printing that I don't pass up directly to the base class is to set the orientation to Landscape.

I'd be happy to let you see the code if it would mean anything to a Delphi man  :wink:

Anonymous

  • Guest
Printing from the plot screen
« Reply #4 on: 08-Nov-2006, 20:15:51 »
I don't have MFC, so the code would have to be plain text, but I did briefly dabble with C++, so I should be able to read the code.

If you would like me to look at the code, I could dig in the archives and look at what I did about 5 years ago. I retired about 3 years ago and haven't looked at a piece of code for anything since then, I'm too busy gliding and acting as Winchmaster at Stratford on Avon GC.

daisearle

  • Registered User
  • *
  • Posts: 4
    • View Profile
Printing from the plot screen
« Reply #5 on: 10-Nov-2006, 16:44:33 »
I attach some Delphi code in the hope it may help.

BTW the reference to canvas is a Delphi property of any graphical device of any size or resolution, so once you have established its properties any graphics function can write to any device's canvas

The first InitPrinter is from a text program, and the second is from a graphics program. The second is the later program, and it implies that the graphics needed an apparently redundant call to the PrinterIndex property to initialise properly.

As you can see from the {comments}, I am confused why I needed to do this second assignment to PrinterIndex. Whether it was Delphi's implementation of the Microsoft functions or the underlying functions I cannot tell, although the forums I visited suggested it was a Microsoft problem (well, they would, wouldn't they!)

Please excuse the diagnostics commented out, plainly I was confused and irritable at the time!

Procedure InitPrinter;
{
for GetPrinter.... if used...
var
hDevMode:THandle;
Device,Driver,Port:array[0..79] of Char;
}
begin
{
  Assumes A4 throughout, to calculate layout dimensions.
  Has to use WINAPI calls to get pixels per inch.
}
  with printer do
  begin
    printerindex:=-1;
{
    The following 2 lines are said to be necessary to ensure change is fully
    implemented:-
    GetPrinter(device,Driver,Port,hDevMode);
    SetPrinter(device,Driver,Port,hDevMode);

    I have also seen:-
    Printer.PrinterIndex:=Printer.PrinterIndex;

    Probably(?) equivalent. I am not using them (apparently without ill effect)
    as I am setting Printer.PrinterIndex anyway.
 }
    begindoc;
    with canvas do
    begin
      InchPixW:=GetDeviceCaps(printer.canvas.Handle,LogPixelsX);
      InchPixH:=GetDeviceCaps(printer.canvas.Handle,LogPixelsY);
      with font do
      begin
  {
      Is this a Windows bug, or a VCL bug(!?)
      The following line is necessary to ensure font scaling is initialised:-
  }
        pixelsperInch:=InchPixH;
        name:='Arial';
        Size:=LmkFontSize;
      end;
      ThinLine:=round(inchpixh / 300);
      if thinline<1 then
        ThinLine:=1;
      BorderWidth:=Thinline*2;
      SetFontSize(LmkFontSize);
  {
      showmessage('Horizontal pixels/in '+inttostr(inchpixw)+#13+
                  'Vertical pixels/in '+inttostr(inchpixh)+#13+
                  'Thin line width '+inttostr(thinline)+#13+
                  'Line height '+inttostr(lineheight));
  }
      pen.color:=clblack;
    end;
  end;
end;

Procedure InitPrinter;
begin
  with printer do
  begin
    printerindex:=-1;
{
The following seems to be necessary (it might be VCL magic!)to ensure
printer change is fully implemented:-
}
    PrinterIndex:=PrinterIndex;

    begindoc;
    XPixPerMm:=round(GetDeviceCaps(printer.canvas.Handle,LogPixelsX)/InToMm);
    YPixPerMm:=round(GetDeviceCaps(printer.canvas.Handle,LogPixelsY)/InToMm);
{
    showmessage(floattostr(GetDeviceCaps(printer.canvas.Handle,HorzSize)));
    showmessage(floattostr(GetDeviceCaps(printer.canvas.Handle,VertSize)));
}
  end;
end;

jeff

  • Administrator
  • Registered User
  • *****
  • Posts: 176
    • View Profile
    • Jeff Goodenough's Pages
Printing from the plot screen
« Reply #6 on: 11-Nov-2006, 16:14:08 »
Hmm. Thanks for posting that. I do quite a bit of that sort of stuff for the straightforward printing, but as I said, it's mostly MFC that does the work for the plot screen printing. If you'd like to wade through CPlotView, I have put the source here.

Take a look at the functions following CPlotView::OnFilePrint(). You'll see that apart from setting the mode to Landscape and calculating the print scale, there is not much special I do in regard to printing.

daisearle

  • Registered User
  • *
  • Posts: 4
    • View Profile
Printing from the plot screen
« Reply #7 on: 11-Nov-2006, 18:12:51 »
From my limited knowledge of C++ you seem to be doing it right.

I can imagine my problem with the laserprinter could be lack of memory in the printer, just at the point where you start to overlay the NOTAMS.

However why the Epson 860 fails baffles me. Both your code and mine are very easy to make device independent, and if the device is initialised and disposed of properly, what can go wrong!

Thanks for your efforts, but unless I can get some printing going somehow, I'll have to pass on Spine, although I've been impressed with what other people have produced with it.

I'll keep playing a bit longer.