Print Page | Close Window

Finding Printer Margins

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=1235
Printed Date: 03 Jul 25 at 10:53AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Finding Printer Margins
Posted By: stakon
Subject: Finding Printer Margins
Date Posted: 13 Oct 09 at 7:54AM
Good Day,

I am using QuickPDF to print some engineering manuals where precision matters.

So when i print a PDF i cannot use the "Page Scaling" option because then the printed dimensions will not be accurate.
The solution is to find the printer margins, and create a cropBox not containing them.
Ideally i would like to make my application print correctly in different printers.
My question is:  Is there a way to find the printer Margins using QuickPDF?

Thanx in advance,

Stakon.




Replies:
Posted By: DELBEKE
Date Posted: 15 Oct 09 at 6:52AM
You can use Wndows apis to find printer margins
    PortraitOffsetX = GetDeviceCaps(Printer.hDC, PHYSICALOFFSETX)
    PortraitOffsetY = GetDeviceCaps(Printer.hDC, PHYSICALOFFSETY)
    PrnWidth = GetDeviceCaps(Dc, PHYSICALWIDTH)
    PrnHeight = GetDeviceCaps(Dc, PHYSICALHEIGHT)


Posted By: stakon
Date Posted: 15 Oct 09 at 9:26AM
Thank you DELBEKE,

    Note that :
    PrnWidth = GetDeviceCaps(Dc, PHYSICALWIDTH)
    PrnHeight = GetDeviceCaps(Dc, PHYSICALHEIGHT)
   
    return the actual paper's width/heigth , not the printable area.

After doing some further research:
    PortraitOffsetX = GetDeviceCaps(Printer.hDC, PHYSICALOFFSETX)
    PortraitOffsetY = GetDeviceCaps(Printer.hDC, PHYSICALOFFSETY)
 
    return the real printer offsets from top and left (ie. the position where the printer can start
     printing)
    the measurement  returned in Device Units which is essentially DU = dpi*inches
    So we have to know our printer's dpi to calculate our document in inches/milimeters
    This is achieved by :
    CPrintDialog dlg(FALSE);
    app->GetPrinterDeviceDefaults(&dlg.m_pd)
    LPDEVMODE devmode = dlg.GetDevMode();
    short dpi = devmode->dmPrintQuality;



   



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk