I'm looking for information how to print to a file and then print from the
file at a later point.
Printing to a file should not be a big issue, but how do I present the file
to the printer at a later moment ?
Any good links and comments will be much appreciated.
If this isn't an option, you can set a printer to print to a file, but I'm
not quite sure how to get it back to the printer later.
You could also look into the PDF format...
Just some ideas...
Eric
Just copy it to the printer port.
> You could also look into the PDF format...
Always a good idea.
Cheers,
Ignacio
You use the Winspool.WritePrinter function for that.
<quote
source="http://codecentral.borland.com/codecentral/ccweb.exe/listing?id=19374
">
Printing a file directly to a printer in Win32, code by Joe Hecht.
Note that you have to include WinSpool in the uses clause.
procedure PrintFile(const sFileName: string);
const
BufSize = 16384;
type
TDoc_Info_1 = record
pDocName: pChar;
pOutputFile: pChar;
pDataType: pChar;
end;
var
Count, BytesWritten: cardinal;
hPrinter: THandle;
Device : array[0..255] of char;
Driver : array[0..255] of char;
Port : array[0..255] of char;
hDeviceMode: THandle;
DocInfo: TDoc_Info_1;
f: file;
Buffer: Pointer;
begin
Printer.PrinterIndex := -1;
Printer.GetPrinter(Device, Driver, Port, hDeviceMode);
if not WinSpool.OpenPrinter(@Device, hPrinter, nil) then exit;
DocInfo.pDocName := 'MyDocument';
DocInfo.pOutputFile := nil;
DocInfo.pDatatype := 'RAW';
if StartDocPrinter(hPrinter, 1, @DocInfo) = 0 then
begin
WinSpool.ClosePrinter(hPrinter);
exit;
end;
if not StartPagePrinter(hPrinter) then
begin
EndDocPrinter(hPrinter);
WinSpool.ClosePrinter(hPrinter);
exit;
end;
System.Assign(f, sFileName);
try
Reset(f, 1);
GetMem(Buffer, BufSize);
while not eof(f) do
begin
Blockread(f, Buffer^, BufSize, Count);
if Count > 0 then
begin
if not WritePrinter(hPrinter, Buffer, Count, BytesWritten) then
begin
EndPagePrinter(hPrinter);
EndDocPrinter(hPrinter);
WinSpool.ClosePrinter(hPrinter);
FreeMem(Buffer, BufSize);
exit;
end;
end;
end;
FreeMem(Buffer, BufSize);
EndDocPrinter(hPrinter);
WinSpool.ClosePrinter(hPrinter);
finally
System.Closefile( f );
end;
end;
</quote>
--
Peter Below (TeamB)
Use the newsgroup archives :
http://www.mers.com/searchsite.html
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be