Forum > General
Custom paper size
(1/1)
Mando:
Hi.
I would like to know how to specify a custom paper size in code.
I've this code that the author said it works in delphi, but do not get it to work in lazarus.
--- Code: --- // +---- Obtener cofiguracion actual ----------------------------------------+
Printer.GetPrinter(FDevice, FDriver, FPort, DeviceMode);
DevMode := GlobalLock(DeviceMode);
// +---- Cambiar configuracion ----------------------------------------------+
DevMode^.dmFields := 0;
if (PaperSize = $100) and (ImpresoraMatricial) then //Personalizado
begin
//showmessage('Es matricial');
DevMode^.dmFields := DM_PAPERLENGTH OR DM_PAPERWIDTH OR DM_PAPERSIZE or DM_SCALE;
DevMode^.dmPaperLength := PaperLength;
DevMode^.dmPaperWidth := PaperWidth;
DevMode^.dmPaperSize := DMPAPER_USER; //Personalizado
DevMode^.dmScale := 100;
end;
DevMode^.dmFields := DevMode^.dmFields OR DM_ORIENTATION;
if Orientation=poPortrait then
DevMode^.dmOrientation := dmOrient_portrait
else
DevMode^.dmOrientation := dmOrient_landscape;
if Copias>0 then
begin
DevMode^.dmFields := DevMode^.dmFields OR DM_COPIES;// OR DM_COLLATE;
DevMode^.dmCopies := Copias;
// DevMode^.dmCollate := DMCOLLATE_FALSE;
end;
// +---- Establecer la configuración ----------------------------------------+
GlobalUnlock(DeviceMode);
Printer.PrinterIndex := Printer.PrinterIndex;
--- End code ---
I know that I can do this:
--- Code: ---Printer.Papersize.Papername:='MyPaper';
--- End code ---
and it works if I defined the papersize "MyPaper" in printer configuration before. But i want defined papersize in code.
I need a solution for windows and impact (matrix) printers.
regards.
Leledumbo:
Play with Printer.Papersize properties (PaperRect, Orientation, etc.). More OO and you get cross-platform solution as a bonus.
Mando:
Thanks for your reply, Leledumbo, but paperRect, orientation... are read-only properties.
Any suggestions?
regards
indalor1:
Hmm, this is a really good question. All I have been able to do so far is jury rig the length of each line just before I set to print. Being able to define the page and paper size would be soo much easier.
Indalor1
Mando:
Nobody knows a solution?
It is very important and I'm desperate.
Regards.
Navigation
[0] Message Index