11 Vote

Lazarus: Print with Document Name

Question by Guest | 2013-12-18 at 18:01

Today, I printed my first page with one of my applications written in Lazarus. This is all working better than I could imagine, but there is also one thing that bothers me a little.

If you click at the printer icon at the Windows Taskbar, a window opens showing the queue of all documents to be printed.

Normally, here, in the column "Document Name" there should be displayed the title of the print. Unfortunately, this title is obviously not passed to the system by Lazarus, the line remains empty at this point.

So far, this is my code:

Printer.BeginDoc;
Printer.Title := 'My first Print';
Printer.Canvas.Font.Name := 'Courier New';
Printer.Canvas.Font.Size := 10;
Printer.Canvas.Font.Color := clBlack; 
Printer.Canvas.TextOut(100, 100, 'TEST');
Printer.EndDoc;

I have tried both, using the property "Title" as well as "FileName" to specify a document name. Both is not working.

Am I doing something wrong or is this a bug of Lazarus?

ReplyPositiveNegative
0Best Answer0 Votes

You are close to the solution. You only have to set the "Title" before the "BeginDoc".

So, for example:

Printer.Title := 'My first Print';
Printer.BeginDoc;
Printer.Canvas.Font.Name := 'Courier New';
Printer.Canvas.Font.Size := 10;
Printer.Canvas.Font.Color := clBlack; 
Printer.Canvas.TextOut(100, 100, 'TEST');
Printer.EndDoc;

At the time of "BeginDoc" the printing has almost begun, so it is too late for setting the name. The name must already be set before the "BeginDoc".
2013-12-21 at 14:56

ReplyPositive Negative
Reply

Related Topics

Rename File to its Folder Name

Tutorial | 0 Comments

Print Word in all System Fonts

Tutorial | 0 Comments

Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.

Participate

Ask your own question or write your own article on askingbox.com. That’s how it’s done.