| |

VerySource

 Forgot password?
 Register
Search
View: 682|Reply: 2

Printer setting paper function, no effect after running

[Copy link]

1

Threads

3

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-1-20 14:40:02
| Show all posts |Read mode
{X = 2290, Y = 2970 After each run, the printer locates the Letter paper, which is very depressed. I hope everyone can give pointers! !! !! }
procedure SetPaperSize (X, Y: Integer);
var
  Device: array [0..255] of char;
  Driver: array [0..255] of char;
  Port: array [0..255] of char;
  hDMode: THandle;
  PDMode: PDEVMODE;
begin
    Printer.PrinterIndex: = Printer.PrinterIndex;
    Printer.GetPrinter (Device, Driver, Port, hDMode);
    // Get the handle value of the printer's DevMode structure, stored in hDMode
    if hDMode <> 0 then begin
       pDMode: = GlobalLock (hDMode);
       // Get a pointer to the DevMode structure of the printer //
       if pDMode <> nil then begin
          pDMode ^ .dmPaperSize: = 256;
          // If you want to change the current printer paper to custom, dmPaperSize must be set to 256
          pDMode ^ .dmPaperLength: = X;
          pDMode ^ .dmPaperWidth: = Y;
          pDMode ^ .dmFields: = pDMode ^ .dmFields or DM_PAPERSIZE;
          pDMode ^ .dmFields: = pDMode ^ .dmFields or DM_PAPERLENGTH;
          pDMode ^ .dmFields: = pDMode ^ .dmFields or DM_PAPERWIDTH;
          {The above three statements set the corresponding dmFields members. }
          ResetDC (Printer.Handle, pDMode ^);

          // Set the value of the printer device environment handle
          GlobalUnlock (hDMode);
          // The following starts to print
       end;
    end;
    Printer.PrinterIndex: = Printer.PrinterIndex;
end;
Reply

Use magic Report

1

Threads

3

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

 Author| Post time: 2020-7-30 00:15:01
| Show all posts
I use the API for custom paper. However, it is found that the printing effect of Textout(x,y,str) is somewhat different:
   With the same parameters of x, y, str, the position printed in A3 and the position I printed on the paper defined by myself are different by 5 mm. Is it necessary to set the top margin when customizing the paper (does the paper have a top margin?)?
Reply

Use magic Report

1

Threads

3

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

 Author| Post time: 2020-7-30 06:45:02
| Show all posts
If custom paper is really not enough, can you use the code to dynamically select A3 paper to print?
I have searched it all on the Internet, and there is no code for dynamic paper selection! ! !
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list