We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to Sign the PDF document using SfPdfViewerControl in WinRT Platform?

Platform: WinRT |
Control: PDF |
.NET Framework: 4.5.1 |
Product Version:
Tags: pdfviewer, signat

How to Sign the PDF document using SfPdfViewerControl in WinRT Platform?

We do not have support for applying Signature in PDF document using SfPdfViewerControl in WinRT at present. However, as a workaround we can Sign the PDF Document by finding the X and Y Coordinates of the PDF document where you can place the signature.

  1. Code Snippet for updating the document once signature is applied

Class: AnnotationEditorViewModel.cs

private void UpdateDocumentCommandClick(object obj)


if (IsInEditMode)


var signPoints = View.CanvasView.AllPoints;


if (signPoints != null && signPoints.Count > 0)



PdfPen pen = new PdfPen(new PdfColor(Constants.SignatureColor.R, Constants.SignatureColor.G, Constants.SignatureColor.B), (float)Constants.SigntureThickness / 2.5f);

var path = new PdfPath();

foreach (var sigPoint in signPoints)


var linePath = new PdfPath();

for (int i = 0; i < sigPoint.Count - 1; i++)


var start = GetDocumentXYPosition(sigPoint[i].X * ScreenToPageConversion, sigPoint[i].Y * ScreenToPageConversion);

var end = GetDocumentXYPosition(sigPoint[i + 1].X * ScreenToPageConversion, sigPoint[i + 1].Y * ScreenToPageConversion);


linePath.AddLine(start, end);







_loadedDocument.Pages[View.CurrentPageIndex].Graphics.DrawPath(pen, path);





View.NaviFrame.Navigate(typeof(PdfEditorView), _loadedDocument);






this.IsInEditMode = !this.IsInEditMode;



  1. Code Snippet to find the X and Y coordinates in a particular page of PDF Document:

Class: AnnotationEditorViewModel.cs

private PointF GetDocumentXYPosition(double pX, double pY)


int currentPageNumber;

float zoomConversionFactor = _zoomFactor / 100.0f;

double pageWidth = _loadedDocument.Pages[View.CurrentPageIndex].Size.Width * zoomConversionFactor;

double pageHeight = _loadedDocument.Pages[View.CurrentPageIndex].Size.Height * zoomConversionFactor;

float pixelPageHeight = _converter.ConvertToPixels((float)pageHeight, PdfGraphicsUnit.Point);

float pixelPageWidth = _converter.ConvertToPixels((float)pageWidth, PdfGraphicsUnit.Point);

float offsetPixelsX, offsetPixelsY;

if (View.ActualWidth > pixelPageWidth)


offsetPixelsX = ((float)View.PdfView.ActualWidth - pixelPageWidth);

offsetPixelsX = (offsetPixelsX / 2.0f);




offsetPixelsX = (zoomConversionFactor) - View.PdfView.HorizontalOffset;


if (View.PdfView.VerticalOffset < pixelPageHeight)


offsetPixelsY = View.PdfView.VerticalOffset -

(View.PdfView.PageGap * zoomConversionFactor);




offsetPixelsY = (View.CurrentPageIndex *

((View.PdfView.VerticalOffset / (View.CurrentPageIndex)) - pixelPageHeight)) -

(View.PdfView.PageGap * (View.CurrentPageIndex + 1) * zoomConversionFactor);



var pointX = (float)pX;

var pointY = (float)pY;

float currentImageLocationY = (View.PdfView.VerticalOffset + pointY) / zoomConversionFactor;


float x = 0.0f, y = 0.0f;



currentPageNumber = (int)Math.Floor(currentImageLocationY / (pixelPageHeight / zoomConversionFactor));


x = _converter.ConvertFromPixels((pointX - offsetPixelsX), PdfGraphicsUnit.Point);

y = _converter.ConvertFromPixels((offsetPixelsY + pointY), PdfGraphicsUnit.Point);


x = x / zoomConversionFactor;

y = y / zoomConversionFactor;



Debug.WriteLine("X={0}, y={1}  -- pX={2}, pY={3}", x, y, pX, pY);

return new PointF(x, y);


Here we are drawing the signature by passing the appropriate Page of PDF document as parameter using Xaml Navigation:

  1. Code Snippet for Xaml Navigation is as follows.

Class Name : AnnotViewer.xaml.cs

protected override void OnNavigatedTo(NavigationEventArgs e)


List<object> parameterList = e.Parameter as List<object>;


_viewModel.LoadedDocument = parameterList[0] as PdfLoadedDocument;

pageIndex = int.Parse(parameterList[1].ToString());

zoomFactor = int.Parse(parameterList[2].ToString());

_currentPageIndex = pageIndex;


float pagewidth = _viewModel.LoadedDocument.Pages[pageIndex].Size.Width;

float pageHeight = _viewModel.LoadedDocument.Pages[pageIndex].Size.Height;


annotViewer = new SfPdfViewerControl();


PdfView = annotViewer;


Image image = annotViewer.GetPage(pageIndex, 300);

image.Width =

unitConvertor.ConvertToPixels(pagewidth, PdfGraphicsUnit.Point);

image.Height = unitConvertor.ConvertToPixels(pageHeight, PdfGraphicsUnit.Point);



You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile