Page size and margins

This Forum is for the use of Software Developers requiring help and assistance for Tracker Software's PDF-Tools SDK of Library DLL functions(only) - Please use the PDF-XChange Drivers API SDK Forum for assistance with all PDF Print Driver related topics or PDF-XChange Viewer SDK if appropriate.

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Tracker Supp-Stefan

Post Reply
g.politi
User
Posts: 27
Joined: Wed Sep 15, 2010 3:05 pm

Page size and margins

Post by g.politi »

Hi,

I wonder if it's possible to get for each page the size (e.g. A4 or 297x210) and the margins.
The margins are useful to avoid to print data outside the printer margins

Thanks for the help

G
User avatar
John - Tracker Supp
Site Admin
Posts: 5219
Joined: Tue Jun 29, 2004 10:34 am
Location: United Kingdom
Contact:

Re: Page size and margins

Post by John - Tracker Supp »

Hi,

there is no way consistent way to extract the page margins I am afraid - technically it could be possible to do so if the file contained this in the 'ArtBox' property - but it is rarely used and will not be in 99% of the files you will have.

With regards the page dimensions - these can be obtained by use of the MediaBox. If the CropBox is set too - get it and intersect with the MediaBox.

See the function : PXCp_PageGetBox etc and also there is an example in the examples folder which should help you get started ..

HTH
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards
Tracker Support
http://www.tracker-software.com
g.politi
User
Posts: 27
Joined: Wed Sep 15, 2010 3:05 pm

Re: Page size and margins

Post by g.politi »

Hi!

thanks for the tip .... I tried using:

iPage := 0;
hr := PXCp_PageGetBox( hDocument, iPage, PB_MediaBox, @rect);

but the value returned in rect doesn't match the document size reported by acrobat read. E.g. the PDF is 8,27 x 11,69 in (standard A4) and the rect return 595 x 841,89.

I guess there's something should be translated from pixel to inch ?

Regards

G
User avatar
Lzcat - Tracker Supp
Site Admin
Posts: 677
Joined: Thu Jun 28, 2007 8:42 am

Re: Page size and margins

Post by Lzcat - Tracker Supp »

Hi.

If you want to deal with PDF files in any depth - you will find it extremely beneficial to review the PDF specification (PDFReference), where you can find a lot of helpful information, including an answer to your question :)

In short - standard unit for PDF dimensions and coordinates is point (pt), which is 1/72 of inch.

The PDF reference is freely available from Adobe's site for all to download and review - as of today's date - this is the correct and current link;

http://www.adobe-direct.com/devnet/pdf/ ... chive.html

HTH.
Victor
Tracker Software
Project manager

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
g.politi
User
Posts: 27
Joined: Wed Sep 15, 2010 3:05 pm

Re: Page size and margins

Post by g.politi »

Thanks for the useful informations!

best regards

G
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17893
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Page size and margins

Post by Tracker Supp-Stefan »

Our Pleasure G! :)

Cheers,
Stefan
Post Reply