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.
Unfortunately, activation email could not send to your email. Please try again.

Split a pdf file

Thread ID:

Created:

Updated:

Platform:

Replies:

119584 Jun 17,2015 08:03 AM Jul 13,2015 07:13 AM General Discussion 26
loading
Tags: General Discussion
kranthi kumar
Asked On June 17, 2015 08:03 AM

Is there any sample code available on how to split pdf files in winrt c# ?

Chinnu Muniyappan [Syncfusion]
Replied On June 18, 2015 04:42 AM

Hi kranthi,
Thank you for using syncfusion products.

We have created a sample for splitting PDF file in WinRT platform, Please find the sample available in the link below,

Sample link:
http://www.syncfusion.com/downloads/support/directtrac/139016/ze/SplitPDF-484838269

Please let us know if you need any further assistance.
Regards,
Chinnu

kranthi kumar
Replied On June 18, 2015 08:01 AM

Thanx a lot!! , can i use the same concept in windows phone 8 too ??

Chinnu Muniyappan [Syncfusion]
Replied On June 19, 2015 08:51 AM

Hi Kranthi.

Yes, we can use the same concept for splitting PDF documents in window phone 8 also, we have created  a simple sample for splitting PDF document in windows phone 8 for your reference, please refer the below sample.

Sample link:
http://www.syncfusion.com/downloads/support/forum/119414/ze/WinPhoneApp-1572264448
Please let us know if you have any further assistance.
Regards,
Chinnu

kranthi kumar
Replied On June 23, 2015 03:30 AM

Can u please provide me a sample for windows phone 8.1 where user picks a pdf file using file picker , i am unable to use pickandcontinue() method correctly during the process.

Chinnu Muniyappan [Syncfusion]
Replied On June 24, 2015 03:08 AM

Hi Kranthi,

As per your requirement we have created a windows phone 8.1 sample to pick a file using FilePicker to spilt the PDF document, please find the sample available in the link below.
Sample link:
http://www.syncfusion.com/downloads/support/directtrac/139704/ze/WinPhoneApp745632063

Please let us know if you need any further assistance.

Regards,
Chinnu

kranthi kumar
Replied On June 24, 2015 08:48 AM

Thanx for your support, the sample u provided is working great!! but when i modified it in a way that user can save the resultant file, i am getting ACESS DENIED error, i used a folder in my pc as sd card for windows phone emulator, here is the code part that i have changed

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using Syncfusion.Pdf;
using Syncfusion.Pdf.Parsing;
using Windows.Storage.Pickers;
using Windows.Storage;
using Windows.Storage.Provider;
using System.Reflection;
using Syncfusion.Pdf.Interactive;
using Windows.UI.Popups;
using Windows.ApplicationModel.Core;
using Windows.ApplicationModel.Activation;
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=391641

namespace WinPhoneApp
{

    public sealed partial class MainPage : Page
    {
        CoreApplicationView view;
        CoreApplicationView sview;
        string filePath = string.Empty;
        MemoryStream ms = new MemoryStream();
        public MainPage()
        {
            this.InitializeComponent();
            view = CoreApplication.GetCurrentView();
            sview = CoreApplication.GetCurrentView();
            this.NavigationCacheMode = NavigationCacheMode.Required;
        }

        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
 
        }
        
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            filePath = string.Empty;
            FileOpenPicker filePicker = new FileOpenPicker();
            filePicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
            filePicker.ViewMode = PickerViewMode.Thumbnail;

            // Filter to include a sample subset of file types
            filePicker.FileTypeFilter.Clear();
            filePicker.FileTypeFilter.Add(".pdf");

            filePicker.PickSingleFileAndContinue();
            
            view.Activated += viewActivated;

        }
        private async void viewActivated(CoreApplicationView sender, IActivatedEventArgs args1)
        {
            FileOpenPickerContinuationEventArgs args = args1 as FileOpenPickerContinuationEventArgs;

            if (args != null)
            {
                if (args.Files.Count == 0) return;

                view.Activated -= viewActivated;
                StorageFile storageFile = args.Files[0];
                var stream = await storageFile.OpenAsync(Windows.Storage.FileAccessMode.Read);
                Stream docStream = stream.AsStreamForRead();

                //loaded the Pdf file
                PdfLoadedDocument ldoc = new PdfLoadedDocument(docStream);

                //Creating a new PDF document
                PdfDocument doc = new PdfDocument();
                doc.ImportPageRange(ldoc, 0, 1);

                doc.Save(ms);

                //trying to save file to user stated location
                var savepicker = new FileSavePicker();
                savepicker.FileTypeChoices.Add("Pdf", new List<string>() { ".pdf" });
                savepicker.SuggestedFileName = "Result";
                savepicker.PickSaveFileAndContinue();
                sview.Activated += sviewActivated;

                //Close the PDF document
                doc.Close(true);
                ldoc.Close(true);
            }
        }

        private async void sviewActivated(CoreApplicationView sender, IActivatedEventArgs args1)
        {
            FileSavePickerContinuationEventArgs args = args1 as FileSavePickerContinuationEventArgs;
            ms.Position = 0;

            if (args != null)
            {
                sview.Activated -= sviewActivated;
                StorageFile stFile = args.File;
                if (stFile != null)
                {
                    Windows.Storage.Streams.IRandomAccessStream fileStream = await stFile.OpenAsync(FileAccessMode.ReadWrite);
                    Stream st = fileStream.AsStreamForWrite();
                    st.SetLength(0);
                    st.Write((ms as MemoryStream).ToArray(), 0, (int)ms.Length);
                    st.Flush();
                    st.Dispose();
                    fileStream.Dispose();
                }

                MessageDialog msgDialog = new MessageDialog("Do you want to view the Document?", "File has been created successfully.");
                UICommand yesCmd = new UICommand("Yes");
                msgDialog.Commands.Add(yesCmd);
                UICommand noCmd = new UICommand("No");
                msgDialog.Commands.Add(noCmd);
                IUICommand cmd = await msgDialog.ShowAsync();
                if (cmd == yesCmd)
                {
                    // Launch the retrieved file
                    bool success = await Windows.System.Launcher.LaunchFileAsync(stFile);
                }

            }
        }

    }
}   

Chinnu Muniyappan [Syncfusion]
Replied On June 25, 2015 09:16 AM

Hi Kranthi,
Thanks for your update.

It is not possible to trigger both open file picker and save file picker in a single button click event and it is a windows limitation. So we have created a sample with two buttons to open and save, Please find the sample available in the link below,

Sample link:
http://www.syncfusion.com/downloads/support/directtrac/133987/ze/WindowPhoneApp1593253692

Please let us know if you need any further assistance.
Regards,
Chinnu

kranthi kumar
Replied On June 25, 2015 12:15 PM

Your sample is working great!! thanx.

Rilfanayasmin Jamal Nasar [Syncfusion]
Replied On June 26, 2015 02:13 AM

Hi Kranthi,
Thank you for your update.
Please let us know if you need any further assistance on this.
Regards,
Yasmin

kranthi kumar
Replied On June 27, 2015 12:13 PM

Is there any property available for PDF page rotation, can i rotate a given page range or all of the pages in a given pdf document?

Chinnu Muniyappan [Syncfusion]
Replied On June 29, 2015 06:57 AM

Hi Kranthi,
Yes, it is possible to Rotate a pages using PageSetting properties, we have created a sample for page rotation, please refer the sample and also find the below code snippet.

C#:

       //Set rotation angle
       doc.PageSettings.Rotate = PdfPageRotateAngle.RotateAngle180;

Sample Link:
http://www.syncfusion.com/downloads/support/forum/119414/ze/RotatePages-1560152297

Please let us know if you need any further assistance.
Regards,
Chinnu


kranthi kumar
Replied On June 30, 2015 06:53 AM

I am using pdfviewer lo load & display the pdf, how can i rotate the page which the viewer is viewing currently ?, is it possible?

Sathish Sivakumar [Syncfusion]
Replied On July 1, 2015 09:11 AM

Hi Kranthi,
Thanks for your update.
Yes, it is possible to rotate the PDF Document being viewed in SfPdfViewer control.
We have created a sample for illustrating rotation being performed in the PDF Document when it is viewed using SfPdfViewer control. Please find the sample in the link below.
Sample:
http://www.syncfusion.com/downloads/support/forum/119414/ze/RotationWinRT-574447116
We have created a new incident for your query regarding “PDF Viewer Control to view PDF Documents in windows phone application”.
Kindly logon to your account to know further details about the new incident in following link.
https://www.syncfusion.com/account/login?ReturnUrl=%2fsupport%2fdirecttrac%2fincidents
Please let us know if you need any other assistance.
Regards,
Sathish Sivakumar

kranthi kumar
Replied On July 1, 2015 09:30 AM

Now u got my point, ur sample is working great thanx!!

Sathish Sivakumar [Syncfusion]
Replied On July 2, 2015 06:23 AM

Hi Kranthi,
Thanks for your feedback.
We are glad to hear that the sample provided by us for rotating PDF Document when it is viewed using SfPdfViewer Control in Windows RT platform is working for you.
Please let us know if you need further assistance.
Regards,
Sathish Sivakumar.

kranthi kumar
Replied On July 2, 2015 10:56 AM

How can i open pdf file protected with owner password (not user password) to change file permissions in a pdfviewer ?

Karthik Krishnaraj [Syncfusion]
Replied On July 3, 2015 07:01 AM

Hi Kranthi,
On analyzing of your requirement for “Need to change permission for pdf document” we faced an issue and have logged defect report regarding this. A support incident to track the status of this defect has been created under your account. Please log on to our support website to check for further updates.
https://www.syncfusion.com/account/login?ReturnUrl=%2fsupport%2fdirecttrac%2fincidents
 Please let me know if you have any questions.
Thanks,
Karthik.

kranthi kumar
Replied On July 3, 2015 07:51 AM

I am getting this error while stamping a pdf in winrt app, am i doing anything wrong ? Error Link

Karthik Krishnaraj [Syncfusion]
Replied On July 6, 2015 06:35 AM

Hi Kranthi,

We are glad to inform you that rotation support is added in Essential PDF for WinRT platform in the upcoming release, which is expected to be rolled out within end of this week. Please let us know if you have any other queries.

Thanks,

Karthik.


kranthi kumar
Replied On July 6, 2015 07:01 AM

I asked about PDF stamping issue but u gave me reply regarding pdf rotation ?

Karthik Krishnaraj [Syncfusion]
Replied On July 7, 2015 07:46 AM

Hi Kranthi,
Thank you for your update,
As per your error snapshot which shows “System.NotImplementedException”, while rotating the text .We used to throw this error message manually, since we have not provided support for rotation of text until the last release(13.1.0.21). Whereas now we have implemented rotation support for winRT platform in upcoming release which is expected to be rolled out within end of the week. If you do not want to rotate the text then you can remove the highlighted code used for rotation.  I have attached a code snippet and a simple sample for your reference below, please have a look through it and let us know if you need any further assistance.

Code Snippet:

PdfGraphics g = lPage.Graphics;

PdfGraphicsState state = g.Save();

g.SetTransparency(0.25f);

g.RotateTransform(-40); //Rotation of text not implemented yet.
g.DrawString("Imported using Essential PDF", font, PdfPens.Red, PdfBrushes.Red, new PointF(50,g.ClientSize.Height/2));

Sample Link:
http://www.syncfusion.com/downloads/support/forum/119414/ze/StampPdf-1839118842
Thanks,
Karthik.


kranthi kumar
Replied On July 9, 2015 01:39 AM

Your solution is working great!! thanx, when can i expect to download the updated release which supports text rotation?

Karthik Krishnaraj [Syncfusion]
Replied On July 10, 2015 12:37 AM

Hi Kranthi,

We are glad to announce that our Essential Studio 2015 Volume 2 Final release version 13.2.0.29 is rolled out and it’s available for download under the following link.

http://www.syncfusion.com/forums/119549/essential-studio-2015-volume-2-final-release-v13-2-0-29-available-for-download

Here in this release we provided support for text rotation in winRT platform.We thank you for your support and appreciate your patience in waiting for this release. Please get in touch with us if you would require any further assistance.

Regards,
Karthik.

kranthi kumar
Replied On July 10, 2015 03:37 AM

As you said i downloaded the latest version of essential studio, i uninstalled the previous version & to my surprise during the uninstall procedure of previous essential studio version all of my Documents folder got wiped out for no good reason!! , how ridiculous is this! , don't u test your products prior to their release??, i am using windows 8.1 pro 64 bit.

Manivannan Sundararajan [Syncfusion]
Replied On July 13, 2015 07:13 AM

Hi Kranthi,

We deeply regret for the inconvenience caused.

If you have installed the Binaries or Samples in Documents folder directly, while uninstalling the setup, immediate root folder will be removed.

We have logged this issue and we will create the parent folder with Syncfusion Version under your root directory. Also it will be included in our upcoming 2015 Vol 2 Service Pack 1 release.

As of now, if you install the setup in Documents or any root directory, please create a subfolder under the root directory and then install the Syncfusion Essential Studio setup.

Please let us know if you need any further assistance on this.

Regards,
Manivannan S.

Manivannan Sundararajan [Syncfusion]
Replied On July 13, 2015 07:13 AM

Hi Kranthi,

We deeply regret for the inconvenience caused.

If you have installed the Binaries or Samples in Documents folder directly, while uninstalling the setup, immediate root folder will be removed.

We have logged this issue and we will create the parent folder with Syncfusion Version under your root directory. Also it will be included in our upcoming 2015 Vol 2 Service Pack 1 release.

As of now, if you install the setup in Documents or any root directory, please create a subfolder under the root directory and then install the Syncfusion Essential Studio setup.

Please let us know if you need any further assistance on this.

Regards,
Manivannan S.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

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.

;