Back to Devexpress

PdfPageTreeObject.CropBox Property

officefileapi-devexpress-dot-pdf-dot-pdfpagetreeobject.md

latest4.5 KB
Original Source

PdfPageTreeObject.CropBox Property

Specifies the crop box imposing the page boundaries displayed in a PDF Viewer.

Namespace : DevExpress.Pdf

Assembly : DevExpress.Pdf.v25.2.Core.dll

NuGet Package : DevExpress.Pdf.Core

Declaration

csharp
public PdfRectangle CropBox { get; set; }
vb
Public Property CropBox As PdfRectangle

Property Value

TypeDescription
PdfRectangle

A PdfRectangle object, specifying the crop box.

|

Remarks

The crop box defines the region to which the contents of the page shall be clipped (cropped) when displayed or printed.

The default setting is the page’s PdfPageTreeObject.MediaBox value.

Note

The PDF page unit of measurement is points, which measures 1/72 of an inch (0.3528 mm). You can convert this unit of measurement, e.g., to pixels using the Units.PointsToPixelsF method.

The following code snippets (auto-collected from DevExpress Examples) contain references to the CropBox property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

office-file-api-ai-implementation/CS/Controllers/SummarizeController.cs#L75

csharp
case PdfPart.FirstPage:
    var firstPageBox = pdfDocumentProcessor.Document.Pages[0].CropBox;
    PdfDocumentPosition pagePosition1 = new PdfDocumentPosition(1, firstPageBox.TopLeft);

how-to-custom-draw-in-pdf-viewer/CS/PDF_Viewer/Form1.cs#L47

csharp
PdfPage page = processor.Document.Pages[rect.PageIndex];
PdfRectangle pageCropBox = page.CropBox;
PdfPoint p1 = new PdfPoint(rect.Point1.X, pageCropBox.Height - rect.Point1.Y);

pdf-document-api-add-graphics-to-landscape-and-portrait-pages/CS/CreateGraphics/Program.cs#L47

csharp
{
    PdfRectangle cropBox = page.CropBox;
    float cropBoxWidth = ConvertFromPdfUnits((float)cropBox.Width, dpiX);

how-to-custom-draw-in-pdf-viewer/VB/PDF_Viewer/Form1.vb#L43

vb
Dim page As PdfPage = processor.Document.Pages(rect.PageIndex)
Dim pageCropBox As PdfRectangle = page.CropBox
Dim p1 As PdfPoint = New PdfPoint(rect.Point1.X, pageCropBox.Height - rect.Point1.Y)

pdf-document-api-add-graphics-to-landscape-and-portrait-pages/VB/CreateGraphics/Program.vb#L41

vb
Private Shared Function PrepareGraphics(ByVal page As PdfPage, ByVal graphics As PdfGraphics, ByVal dpiX As Single, ByVal dpiY As Single) As SizeF
    Dim cropBox As PdfRectangle = page.CropBox
    Dim cropBoxWidth As Single = ConvertFromPdfUnits(CSng(cropBox.Width), dpiX)

See Also

MediaBox

ArtBox

BleedBox

TrimBox

PdfPageTreeObject Class

PdfPageTreeObject Members

DevExpress.Pdf Namespace