Back to Devexpress

PdfViewerControl.GetPageInfo(Int32) Method

wpf-devexpress-dot-xpf-dot-pdfviewer-dot-pdfviewercontrol-dot-getpageinfo-x28-system-dot-int32-x29.md

latest2.9 KB
Original Source

PdfViewerControl.GetPageInfo(Int32) Method

Obtains information (crop box and rotation angle) about a specific page.

Namespace : DevExpress.Xpf.PdfViewer

Assembly : DevExpress.Xpf.PdfViewer.v25.2.dll

NuGet Package : DevExpress.Wpf.PdfViewer

Declaration

csharp
public PdfPageInfo GetPageInfo(
    int pageNumber
)
vb
Public Function GetPageInfo(
    pageNumber As Integer
) As PdfPageInfo

Parameters

NameTypeDescription
pageNumberInt32

The page number for which information should be obtained.

|

Returns

TypeDescription
PdfPageInfo

An object that contains page information (crop box and rotation angle).

|

Remarks

Use the GetPageInfo method to retrieve page information and calculate coordinates correctly. The code sample below shows how to use the retrieved information to insert a sticky note at the first page’s top right corner:

csharp
private void pdfViewer_DocumentLoaded(object sender, System.Windows.RoutedEventArgs e)
{
    var pageInfo = pdfViewer.GetPageInfo(1);
    var cropBox = pageInfo.CropBox;

    PdfPoint stickyNotePoint = new PdfPoint(cropBox.Right - 20, cropBox.Top - 20);

    var points = new[] { new PointF((float)stickyNotePoint.X, (float)stickyNotePoint.Y) };

    PdfDocumentPosition stickyNotePosition = new PdfDocumentPosition(1, new PdfPoint(points[0].X, points[0].Y));
    var stickyNoteColor = System.Windows.Media.Color.FromRgb(214, 222, 4);
    pdfViewer.AddStickyNote(stickyNotePosition, "Note", stickyNoteColor);
}
vb
Private Sub pdfViewer_DocumentLoaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs)
  Dim pageInfo = pdfViewer.GetPageInfo(1)
  Dim cropBox = pageInfo.CropBox

  Dim stickyNotePoint As New PdfPoint(cropBox.Right - 20, cropBox.Top - 20)

  Dim points = { New PointF(CSng(stickyNotePoint.X), CSng(stickyNotePoint.Y)) }

  Dim stickyNotePosition As New PdfDocumentPosition(1, New PdfPoint(points(0).X, points(0).Y))
  Dim stickyNoteColor = System.Windows.Media.Color.FromRgb(214, 222, 4)
  pdfViewer.AddStickyNote(stickyNotePosition, "Note", stickyNoteColor)
End Sub

See Also

PdfViewerControl Class

PdfViewerControl Members

DevExpress.Xpf.PdfViewer Namespace