using it.stefanochizzolini.clown.documents; using it.stefanochizzolini.clown.files; using it.stefanochizzolini.clown.tools; namespace it.stefanochizzolini.clown.samples { /** This sample demonstrates how to split a document into its constituting pages. */ public class SplitSample : ISample { public void Run( PDFClownSampleLoader loader ) { // (boilerplate user choice -- ignore it) string filePath = loader.GetPdfFileChoice("Please select a PDF file"); // 1. Open the the PDF file! File file = new File(filePath); // Get the PDF document! Document document = file.Document; // 2. Splitting the document into single-page documents... int index = 0; int pagesCount = document.Pages.Count; foreach(Document pageDocument in new PageManager(document).Split()) { // (boilerplate metadata insertion -- ignore it) loader.BuildAccessories(pageDocument,this.GetType(),"Split (" + (index + 1) + "/" + pagesCount + ")","splitting a PDF file into its constituting pages"); // Page file serialization (again, boilerplate code -- see the PDFClownSampleLoader class source code). loader.Serialize(pageDocument.File,this.GetType().Name + "." + (++index),false); } } } }