?
Solved

Non-printable-areas of a printer

Posted on 2005-04-13
15
Medium Priority
?
550 Views
Last Modified: 2010-04-05
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' ?
0
Comment
Question by:Treppenmeister
  • 6
  • 4
  • 4
  • +1
15 Comments
 
LVL 15

Expert Comment

by:mikelittlewood
ID: 13770848
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
 

Author Comment

by:Treppenmeister
ID: 13771250
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
 
LVL 15

Expert Comment

by:mikelittlewood
ID: 13771323
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 6

Expert Comment

by:pritaeas
ID: 13771379
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
 
LVL 15

Expert Comment

by:mikelittlewood
ID: 13771407
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
 
LVL 11

Accepted Solution

by:
pcsentinel earned 800 total points
ID: 13771476
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
 

Author Comment

by:Treppenmeister
ID: 13772621
@ 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
 
LVL 11

Expert Comment

by:pcsentinel
ID: 13773088
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
 

Author Comment

by:Treppenmeister
ID: 13773297
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
 
LVL 11

Expert Comment

by:pcsentinel
ID: 13773554
Sorry my prog only handles text, but graphics isn't that hard to add

regrds
0
 
LVL 15

Expert Comment

by:mikelittlewood
ID: 13773647
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
 

Author Comment

by:Treppenmeister
ID: 13773713
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
 

Author Comment

by:Treppenmeister
ID: 13773778
@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
 
LVL 11

Expert Comment

by:pcsentinel
ID: 13774134
Yes the preview is resizable, It uses a metafilecanvas, small resoultions are handled internally

U.K.

0
 

Author Comment

by:Treppenmeister
ID: 13779118
You can contact me under

ValidOnlyApril2005 @ treppenmeister.com
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question