If you look at the TPrintDialog (Using Aivar's Plugin Script Tree Plugin, you'll notice that it's very limited, and doesn't have support for headers/footers etc.)
I think Blumenthals will have to implement an extended printdialog or something like this:
http://yacs.lebeausoftware.org/TaeRichEditInfo.html"The TaeRichEdit Component is a full-featured TRichEdit analogue. It supports Rich Edit 2.0 & 3.0 character and paragraph formatting; provides OLE support (including embedded graphics);
expands printing options to include headers, footers, and border lines; and much more. The Borland C++ Builder (no Delphi) source is included. The component is free for non-commercial use."
The above page also contains a lot of useful info in the "Papers" section, about TRichEdit and how to print the content.
Another option, is to create a Plugin that uses ActiveX to transfer editor content to MS Word. Then the printer output is done by MS Word, which has support for Headers/Footers etc.
Simple example that prints current page using MS Word.:
- Code: Select all
var fname = Document.FileName;
if (fname == "") fname = Document.FtpFileName;
var data = Editor.Text;
var objWord = CreateOleObject("Word.Application");
objWord.Visible = false;
objWord.Documents.Add();
var ActiveDocument = objWord.Documents(1);
// Add Header
var Header = ActiveDocument.Sections(1).Headers(1).Range;
Header.Text = fname;
Header.ParagraphFormat.Alignment = 0; // 0 = left, 1 = center, 2 = right
Header.Font.Name = "Arial";
Header.Font.Size = 12;
// Add Footer
var Footer = ActiveDocument.Sections(1).Footers(1).Range;
Footer.Text ="My Custom Footer";
Footer.ParagraphFormat.Alignment = 0; // 0 = left, 1 = center, 2 = right
Footer.Font.Name = "Arial";
Footer.Font.Size = 12;
// Add pagenumbers to footer
ActiveDocument.Sections(1).Footers(1).PageNumbers.Add(2, true); // 0 = left, 1 = center, 2 = right
// Insert text from editor
var rng = ActiveDocument.Range(0, 0);
rng.Text = data;
rng.Select();
// Activate print dialog
ActiveDocument.PrintOut();
objWord.Documents.Close(0);
objWord.Quit();
The example uses the filename for the Header, and a custom text/page number for the Footer.