Desktop Products:

Process Automation:

Software Development:

PDF'i Word'e Dönüştürücü Müşteriler

Solid Framework Code Sample

This is a concise sample to help get started with Solid Framework SDK

Extract Single PDF Pages from a Multiple Page PDF File

In this tutorial we show you how to extract and save single pages of a multiple paged PDF file into separate PDF files.

Extract Single PDF Pages from a Multiple Page PDF File

Click to play Code Walk Through Video

Steps to creating single PDF files from a Multipage PDF File

  1. Import the trial Developer License:

    License.Import(new StreamReader(@"C:\Users\Joe\license.xml"));

  2. Allow multi selection of only PDF files using OpenFileDialog:

    // Create a Open File Dialog that allows you to select multiple files
    OpenFileDialog OpFile = new OpenFileDialog();
    OpFile.Multiselect = true;

    //show only PDF Files
    OpFile.Filter = "PDF Files (*.pdf)|*.pdf";

    //Do nothing if someone clicks on cancel
    if (OpFile.ShowDialog() != System.Windows.Forms.DialogResult.OK)

  3. Use PagesModel to split the file:

    //Create a new PagesModel object and open the selected file.
    PagesModel model = new PagesModel();

  4. Create a loop with a defined int called pageIndex set to zero to count the pages:

    //Define a string called partsFolder to get the directory information for the selected file
    String partsFolder = Path.GetDirectoryName(OpFile.FileName);
    partsFolder = Path.Combine(partsFolder, Path.GetFileNameWithoutExtension(OpFile.FileName));

    if (model.Count > 1) //If the PDF has more than one page then count the pages
        for (int pagelndex = 0;
        pagelndex < model.Count;
        pagelndex++ // same as saying “pagelndex = pagelndex + 1”


  5. Clear model of any selection and add the new pageIndex:


  6. Manage if there is only one page in the selected file:

    //Name the extracted pages to the source file name plus the page number it relates to using pageIndex
    String path = Path.Combine(partsFolder, Path.GetFileName(OpFile.FileName));
    path = Path.ChangeExtension(path, "." + (pageIndex + 1).ToString() + ".pdf");


  7. Save and extract the pages:

    model.Save(path, true);

  8. Just save a copy if the selected file only has one page:

    else // If there is only one page in the selected PDF File
       String path = Path.Combine(partsFolder, Path.GetFileName(OpFile.FileName));

       path = Path.ChangeExtension(path, ".1.pdf");

       File.Copy(OpFile.FileName, path, true);

       File.SetAttributes(path, FileAttributes.Normal); // make sure the copy is not readonly

  9. Close Model:



Site Haritası
©2000-2018 Solid Documents Limited - Tüm Hakları Saklıdır