Welcome Guest! To enable all features please Login or Register.



Go to last post Go to first unread
Paul Rayman  
#1 Posted : Thursday, June 8, 2017 11:22:01 PM(UTC)
Paul Rayman

Rank: Administration

Groups: Administrators
Joined: 1/5/2016(UTC)
Posts: 935

Thanks: 3 times
Was thanked: 112 time(s) in 109 post(s)
Is there a way in winform PDF viewer to get the x,y,width and height of the bleedbox and trimbox from a pdf page?

You can get access to these boundaries through page dictionary.
Here's an example:

var doc = PdfDocument.Load(@"d:\0\9\mp4.pdf");
var pageDict = doc.Pages[0].Dictionary;
FS_RECTF cropBox = ConvertToPdfRect(pageDict["CropBox"] as PdfTypeArray);
FS_RECTF bleedBox = ConvertToPdfRect(pageDict["BleedBox"] as PdfTypeArray);
FS_RECTF trimBox = ConvertToPdfRect(pageDict["TrimBox"] as PdfTypeArray);

private static FS_RECTF ConvertToPdfRect(PdfTypeArray cropBoxArray)
    return new FS_RECTF()
        left = (cropBoxArray[0] as PdfTypeNumber).FloatValue,
        bottom = (cropBoxArray[1] as PdfTypeNumber).FloatValue,
        right = (cropBoxArray[2] as PdfTypeNumber).FloatValue,
        top = (cropBoxArray[3] as PdfTypeNumber).FloatValue

Please note the these boundaries are given in PDF user scope coordinate system.
To convert them to PdfViewer coordinate system you should call PageToCient method

Edited by user Thursday, June 8, 2017 11:24:04 PM(UTC)  | Reason: Not specified

Users browsing this topic
Forum Jump  
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.