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 reorder PDF pages using ListView?

Platform: UWP |
Control: SfPdfViewer |
Published Date: May 31, 2018 |
Last Revised Date: July 5, 2018

You can rearrange the PDF pages by extracting the pages as images using PDF viewer, loading them into a ListView, and dragging to the position you need. The rearranged PDF can be saved using the PdfLoadedDocument.


Include a ListView to load the pages and a button to save the PDF. The CanReorderItems, CanDragItems, and AllowDrop properties of the ListView must be set to “True”. Add a Grid that contains an Image control to the ListView’s ItemTemplate. The pages are rendered on these Image controls.




Add a new class named CustomImage to the project. It must have two properties of type ImageSource and int with the names PageImageSource and PageNumber respectively. The Source property of the Image control in the ListView’s ItemTemplate can bound to the PageImageSource property. The other integer property helps to identify the original page number associated with the image.





Add a ViewModel class to the project with the name “RearrangePagesViewModel”. Define a property of type ObservableCollection<CustomImage> in this class. The ItemsSource property of the ListView must bound to this property as shown in the previous XAML code. 

Implement the logic of exporting the PDF pages as images using PDF viewer and adding them to the PageList in the constructor of the RearrangePagesViewModel class. Define an asynchronous method that implements this logic and call the method from the constructor, as the keyword async cannot be used with the constructor.




In the main page of the project, get the stream of the PDF to be loaded and create a PdfLoadedDocument instance and in the constructor, initialize the RearrangePagesViewModel class. Define and wire a handler method for the Click event  of the save button as shown in the XAML code. In this method, implement the logic to save the PDF with the current page order as displayed in the ListView. The file is saved to the LocalFolder of the application.




Sample link:


2X faster development

The ultimate UWP UI toolkit to boost your development speed.
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