Non-printable-areas of a printer

How it is possible to get the information how big the non-printable area of a printer is.

Printer.PageWidth and Printer.PageHeight tell me only the size of the printable area.
But how to tell the width of the 'edge-areas' ?
TreppenmeisterAsked:
Who is Participating?
 
pcsentinelCommented:
The code below is a straight rip from one of my progs.

you need to use getdevicecaps

GetDeviceCaps(Printer.Handle,Physicalwidth);
gives you the physical width of the page in device units

GetDeviceCaps(Printer.Handle,Physicalheight);
gives you the physical height of the page in device units

GetDeviceCaps(Printer.Handle,Physicaloffsetx);
gives you the difference between the physical left of the page i.e. 0 and the first printable part of the page i.e. the left margin

GetDeviceCaps(Printer.Handle,Physicaloffsety);
gives you the difference between the physical top of the page i.e. 0 and the first printable part of the page i.e. the top margin

the acutual height & width of the printabe area you already know fromyour question

function TReportDef.GetPageData(RepType: TOutputType): boolean;
// Retrieve the saved printer setup from the report definition file
var
  lPageSetup: TPageSetup;
begin

  Printer.Canvas.Font.Name:=lPageSetup.FontName;
  Printer.Canvas.Font.Size:=lPageSetup.BaseFontSize;
  Printer.Canvas.Font.Style:=[];
  Printer.Canvas.Font.Color:=clBlack;
  Printer.Orientation:=lPageSetup.Orientation;
  FPhysWidthPix:=GetDeviceCaps(Printer.Handle,Physicalwidth);
  FPhysHeightPix:=GetDeviceCaps(Printer.Handle,Physicalheight);
  FPhysleftOffsetpix:=GetDeviceCaps(Printer.Handle,Physicaloffsetx);
  FPhysTopOffsetPix:=GetDeviceCaps(Printer.Handle,Physicaloffsety);
  FHorzPi:=GetDeviceCaps(Printer.Handle,LogPixelsX);
  FVertPi:=GetDeviceCaps(Printer.Handle,LogPixelsY);
  FLeftMarginPix:=trunc((lPageSetup.Margins.Left/25.4)*FHorzPi);
  FRightMarginPix:=trunc((lPageSetup.Margins.Right/25.4)*FHorzPi);
  FTopMarginPix:=trunc((lPageSetup.Margins.Top/25.4)*FVertPi);
  FBottomMarginPix:=trunc((lPageSetup.Margins.Bottom/25.4)*FVertPi);
  FPrintWidthPix:=FPhysWidthPix-FLeftMarginPix-FRightMarginPix;
  FPrintHeightPix:=FPhysHeightPix-FTopMarginPix-FBottomMarginPix;
  Result := True;
end;


regards
0
 
mikelittlewoodCommented:
There are no "edge-areas" unless you are using something like Word and setting page settings. Its an application thing.
You can print right to the edges of any page of a printer.
You can test this by using the Printer.Canvas to print something directly to it.
0
 
TreppenmeisterAuthor Commented:
Perhaps I was not clear enough. If I have for instance a A4-page, then the page is about 297x210 mm, but the printing area differs from printer to printer. It is for instance only 285 x 200 mm. What I am looking for is the width of the non-printable edge at the top, the bottom, the left and the right.

The aim is to print something with a specific distance from the page border - and not from the border of the canvas.

0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

 
mikelittlewoodCommented:
But if you are just using a standard application, this printing area is user set, not printer set.
How are you trying to print anyway? Are you manually printing to the canvas, or using the typical print dialog/print settings with delphi.

I still disagree on the border thing to be printer specific and actually set per printer.
Ive just tested 3 different printers here and I have no issue with border if I print directly to the printer canvas.

0
 
pritaeasSoftware EngineerCommented:
I think he is referring to the hardware limitations of the (older) printers.(I also still have some older printers, where the border sizes vary due to hardware limits. The print-head cannot reach the border of the paper in these cases.)  I doubt that you can retrieve that information.
0
 
mikelittlewoodCommented:
Ahh ... then if pritaeas is correct in his assumption about what type of printer you are using, I would agree.
If it is a modern printer, this would never be an issue.
0
 
TreppenmeisterAuthor Commented:
@ pcsentinel:

This was exactly what I was looking for. To my surprise the left and right margins and the top and bottom margins are not always the same. I always thought that it was symmetrically.
0
 
pcsentinelCommented:
No, I know to my cost that there not. This all came about from writing a print preview program and having to position text on a page

good luck
0
 
TreppenmeisterAuthor Commented:
Thanks for your help.
I want to do something similar - but with text, graphics and bitmaps. Is your program a professional program and ready? If it is - perhaps we would be interested to buy a license to use it in our application. It would save me a little bit of time.

If you are interested - is there a way to send here a PM ?
0
 
pcsentinelCommented:
Sorry my prog only handles text, but graphics isn't that hard to add

regrds
0
 
mikelittlewoodCommented:
If you know exactly where you want the images to be displayed on the printer canvas, you could directly overlay images straight onto it for printing.
Its a bit more time consuming when you have to work with pixels/printer units, but once you have a good routine written it works well.
I had to do a similar print preview program to handle this sort of thing, but it is not very generalised that I could give you something to work with.
0
 
TreppenmeisterAuthor Commented:
Is the preview resizable? Do you use a canvas? How do you avoid problems with small resolutions?
If you are interested to sell a license - please tell me what functions the program supports and I will create in the meanwhile a temporary e-mail-adress - which I could publish here and we could continue talking outside of this forum. But for today I have to go.
P.S. Where are you from?
0
 
TreppenmeisterAuthor Commented:
@mikelittlewood:
I have already a preview - but I am not content with the quality. So I am looking for a substitution. I am also using the preview to rearrange the position of the bitmaps.
0
 
pcsentinelCommented:
Yes the preview is resizable, It uses a metafilecanvas, small resoultions are handled internally

U.K.

0
 
TreppenmeisterAuthor Commented:
You can contact me under

ValidOnlyApril2005 @ treppenmeister.com
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.