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 split a PDF document and store it to custom folder in WinRT

Platform: WinRT |
Control: PDF
Tags: pdf, winrt

How to split a PDF document and store it to custom folder in WinRT

To split a single PDF document into multiple PDF documents you can use ImportPage or ImportPageRange method of PdfDocument object. Use windows FolderPicker to choose custom folder and store all the split PDF files. The following code example explains the same.


        private async void Button_Click(object sender, RoutedEventArgs e)



            Stream docStream = typeof(MainPage).GetTypeInfo().Assembly.GetManifestResourceStream("SplitPDF.Assets.sample.pdf");

            //load the existing document

            PdfLoadedDocument ldoc = new PdfLoadedDocument(docStream);


            List<MemoryStream> ms = new List<MemoryStream>();


            for (int i = 0; i < ldoc.Pages.Count; i++)


                //Create a new Pdf document

                PdfDocument doc = new PdfDocument();


                //import the page

                doc.ImportPage(ldoc, i);


                MemoryStream file = new MemoryStream();


                //save the document





                //Close the document








private async void Save(List<MemoryStream> stream)


            //select the folder to store the PDF files.

            FolderPicker picker = new FolderPicker();

            picker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;


            StorageFolder stFile = await picker.PickSingleFolderAsync();

            //save the PDF document

            for (int i = 0; i < stream.Count;i++)


                StorageFile file = await stFile.CreateFileAsync("sample"+i+".pdf",Windows.Storage.CreationCollisionOption.ReplaceExisting);

                stream[i].Position = 0;

                var buffer = new byte[(int)stream[i].Length];

                await stream[i].ReadAsync(buffer, 0, buffer.Length);

                await Windows.Storage.FileIO.WriteBytesAsync(file, buffer);




Sample link:



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