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

Notification

Icon
Error

Options
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: 814

Thanks: 1 times
Was thanked: 100 time(s) in 98 post(s)
Question:
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?
Thanks.

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

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
https://pdfium.patagames.com/help/html/563e2f2f-957a-dbf2-55a5-ca8368e609c4.htm

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.