Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!
![]() |
Finding Printer Margins |
Post Reply ![]() |
Author | |
stakon ![]() Team Player ![]() Joined: 09 Oct 09 Status: Offline Points: 22 |
![]() ![]() ![]() ![]() ![]() 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. |
|
![]() |
|
DELBEKE ![]() Debenu Quick PDF Library Expert ![]() ![]() Joined: 31 Oct 05 Location: France Status: Offline Points: 151 |
![]() ![]() ![]() ![]() ![]() |
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) |
|
![]() |
|
stakon ![]() Team Player ![]() Joined: 09 Oct 09 Status: Offline Points: 22 |
![]() ![]() ![]() ![]() ![]() |
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; |
|
![]() |
Post Reply ![]() |
|
Tweet
|
Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |
Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. About — Contact — Blog — Support — Online Store