Can't print anything in Lazarus lazarus / 8-Other ---------------------------------------------------------------------- new user · 2005-06-27 06:33 I can't use the unit printers, even if i intitalize the printer class it still doesn't work. Can anyone send me a working example of a program that rints some text using the printers unit. I heard something abou the printer4lazarus package but i don't seem to find it anyware. If anyone can help me pleeeeeease do. ---------------------------------------------------------------------- Anonymous · 2005-06-27 06:34 I forget to mention that i need that example for win32 ---------------------------------------------------------------------- Anonymous · 2005-06-27 06:35 my email: marius_cuciureanu@yahoo.com ---------------------------------------------------------------------- Vincent Snijders · 2005-06-27 08:36 The printersforlazarus packages can be found in \components\printers\printers4lazarus.lpk. ---------------------------------------------------------------------- matthijs · 2005-06-27 08:54 Place a PrintDialog on your form and then do something like: Code: [Select] begin   if PrintDialog1.Execute do begin     Printer.BeginDoc;     Printer.Canvas.Font.Name := 'Arial';     Printer.Canvas.Font.Size := 10;     H := Printer.Canvas.TextHeight('Gg') + 2;     for Line := 0 to Memo1.Lines.Count do begin       Printer.Canvas.TextOut(25, 25 + Line * H, Memo1.Lines[Line]);     end;     Printer.EndDoc;   end; end; Setting the font is necessary because Linux standard choose a rather large font and Windows uses a very small font by default. ---------------------------------------------------------------------- Anonymous · 2005-06-29 09:59 i just reinstaled lazarus and i can't find the directory printers i searched exactly where u said c:\lazarus\components ---------------------------------------------------------------------- Anonymous · 2005-06-29 10:01 it's ok i found it, but i had to download it from the website because the install kit for windows doesn't seem to have it ---------------------------------------------------------------------- Anonymous · 2005-06-29 10:51 when i try to install the package i get a lot of errors: in winprinters it says that i can't override some methods from TPrinter because they do not exist, the funny thing is that they do exist and they are protected, i still can't get it to work ---------------------------------------------------------------------- matthijs · 2005-06-29 11:48 Quote from: "Anonymous"it's ok i found it, but i had to download it from the website because the install kit for windows doesn't seem to have it Oeps :oops: Have a look at this page for a link to the latest Windows Installer and try to install that. I guess is you are running Lazarus 0.9.6 and with that beta release printers is not yet a standard part of the package. If you use the "Snapshot" things might work out better. ---------------------------------------------------------------------- Anonymous · 2005-06-30 08:42 ok, thanks man i'm downloading lazarus 0.9.7 right now, hope it will work ---------------------------------------------------------------------- DougNettleton · 2005-06-30 15:18 Hi everyone, Just became a member.  I download the latest Windows Snapshot regularly and am quite impressed with what has been accomplished so far with Lazarus.  I'm trying to get together some useful routines for printing.  When I do the following ...   Printer.BeginDoc;   Printer.Canvas.Font.Name := 'Courier New';   Printer.Canvas.Font.Size := 50;   Printer.Canvas.Font.Style := [fsBold];   XPos := 300;   YPos := 300;   Printer.Canvas.TextOut(XPos,YPos,'Here''s Some Test Output');   YPos := YPos + Printer.Canvas.TextHeight('Gg');   Printer.Canvas.TextOut(XPos,YPos,'Here''s Some More Output'); with a postscript driver printer set at 300dpi, it appears that the printer.canvas.font.size value is in pixels - not points.  Is this standard in Lazarus?  I.e. should I be setting font.size to desired size in points  * resolution / 72?  TIA. ---------------------------------------------------------------------- mutek · 2005-07-08 13:31 Hello, >begin >  if PrintDialog1.Execute do begin >    Printer.BeginDoc; >    Printer.Canvas.Font.Name := 'Arial'; >    Printer.Canvas.Font.Size := 10; >    H := Printer.Canvas.TextHeight('Gg') + 2; >    for Line := 0 to Memo1.Lines.Count do begin >      Printer.Canvas.TextOut(25, 25 + Line * H, Memo1.Lines[Line]); >    end; >    Printer.EndDoc; >  end; >end; Which is it a type of of "Printer" variable in this example? ---------------------------------------------------------------------- glober · 2005-07-19 23:31 Quote from: "mutek"Hello, >begin >  if PrintDialog1.Execute do begin >    Printer.BeginDoc; >    Printer.Canvas.Font.Name := 'Arial'; >    Printer.Canvas.Font.Size := 10; >    H := Printer.Canvas.TextHeight('Gg') + 2; >    for Line := 0 to Memo1.Lines.Count do begin >      Printer.Canvas.TextOut(25, 25 + Line * H, Memo1.Lines[Line]); >    end; >    Printer.EndDoc; >  end; >end; Which is it a type of of "Printer" variable in this example? Printer is of type TPrinter in the given example, you have to put 'Printers' in your uses clause. The code given is not a good example because 'printer' is a reserved word,   and should reference it in the following way:Code: [Select] var MyPrinter: TPrinter; begin   if PrintDialog1.Execute do begin     MyPrinter := Printer;     MyPrinter.BeginDoc;     MyPrinter.Canvas.Font.Name := 'Arial';     MyPrinter.Canvas.Font.Size := 10;     H := MyPrinter.Canvas.TextHeight('Gg') + 2;     for Line := 0 to Memo1.Lines.Count do begin       MyPrinter.Canvas.TextOut(25, 25 + Line * H, Memo1.Lines[Line]);     end;     MyPrinter.EndDoc;   end; end; ---------------------------------------------------------------------- matthijs · 2005-07-20 03:46 As far as I know "Printer" is an instance off TPrinter, created automatically and can be used without any problem. It certainly is not a reserved word! ---------------------------------------------------------------------- glober · 2005-07-20 04:04 Quote from: "matthijs"As far as I know "Printer" is an instance off TPrinter, created automatically and can be used without any problem. It certainly is not a reserved word! It is reserved in the sense that it doesn't work the way you use it. I tried your code, and I get a SIGSEGV under IDE, or Access Violation running the executable. Doing it my way works fine. ---------------------------------------------------------------------- Anonymous · 2006-01-13 04:11 How to set Orientation to Landscape, cause i'l have a problem to print my document in Landscape mode? The Result printing it's same with Portrait mode.