{"id":117,"date":"2011-04-07T13:01:00","date_gmt":"2011-04-07T13:01:00","guid":{"rendered":"http:\/\/madprogrammer76.wordpress.com\/2011\/04\/07\/how-to-split-a-pdf-using-pdfsharp"},"modified":"2011-04-07T13:01:00","modified_gmt":"2011-04-07T13:01:00","slug":"how-to-split-a-pdf-using-pdfsharp","status":"publish","type":"post","link":"http:\/\/andrewpallant.ca\/wordpress\/how-to-split-a-pdf-using-pdfsharp\/","title":{"rendered":"How To Split A PDF Using PdfSharp"},"content":{"rendered":"<p>I recently completed a project which broker a PDF file into multiple files from which I converted to a MS Excel file and ultimately processed the data into a database.<\/p>\n<p>This segment is dealing with the portion for splitting a multi-page Adobe PDF file into multiple pages.   I mostly do this step, because we will be storing the individual page into a document management system along with the data that we strip from it.  This page will be used later by our data entry clerks.<\/p>\n<p>When breaking down to individual pages, we need to ensure that we keep the integrity of the original page.   This ensures we can still convert to an Excel file to get the data from it.  <\/p>\n<p>There are many open-source and free PDF SDK  kits that you can try.   I had best luck doing most any PDF work using PdfSharp ( <a href=\"http:\/\/pdfsharp.com\/PDFsharp\/\" target=\"_new\">http:\/\/pdfsharp.com\/PDFsharp\/<\/a> ).   Here is a modified code segment of how you can use PdfSharp to split.<\/p>\n<p><\/p>\n<pre style=\"border:1px inset silver;background-color:#FFFFEA;font-size:8pt;\">Int32 iCount = 0;<br \/><br \/>PdfDocument inputDocument = PdfReader.Open(filename, PdfDocumentOpenMode.Import);<br \/>String directory = @\"C:temp\";<br \/>string name = Path.GetFileNameWithoutExtension(filename);<br \/>for (int idx = 0; idx &lt; inputDocument.PageCount; idx++)<br \/>{<br \/>    iCount++;<br \/>    toolStripStatusLabel2.Text = \" - Processing File# \" + iCount + \" of \" + inputDocument.PageCount;<br \/>    Application.DoEvents();<br \/><br \/>    \/\/ Create new document<br \/>    PdfDocument outputDocument = new PdfDocument();<br \/>    outputDocument.Version = inputDocument.Version;<br \/>    outputDocument.Info.Title = String.Format(\"Page {0} of {1}\", idx + 1, inputDocument.Info.Title);<br \/>    outputDocument.Info.Creator = inputDocument.Info.Creator;<br \/><br \/>    \/\/ Add the page and save it<br \/>    outputDocument.AddPage(inputDocument.Pages[idx]);<br \/>    outputDocument.Save(Path.Combine(directory , String.Format(\"{0} - Page {1}.pdf\", name, idx + 1)));<br \/>}<br \/><\/pre>\n<div class=\"blogger-post-footer\"><img width='1' height='1' src='https:\/\/blogger.googleusercontent.com\/tracker\/4951456985313329413-9061186051406002766?l=softwaredeveloperinlondon.blogspot.com' alt='' \/><\/div>\n","protected":false},"excerpt":{"rendered":"<p>I recently completed a project which broker a PDF file into multiple files from which I converted to a MS Excel file and ultimately processed the data into a database. This segment is dealing with the portion for splitting a multi-page Adobe PDF file into multiple pages. I mostly do this step, because we will &hellip; <a href=\"http:\/\/andrewpallant.ca\/wordpress\/how-to-split-a-pdf-using-pdfsharp\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">How To Split A PDF Using PdfSharp<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13,60,77],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v23.9 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\r\n<title>How To Split A PDF Using PdfSharp - LDNDeveloper<\/title>\r\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\r\n<link rel=\"canonical\" href=\"http:\/\/andrewpallant.ca\/wordpress\/how-to-split-a-pdf-using-pdfsharp\/\" \/>\r\n<meta property=\"og:locale\" content=\"en_US\" \/>\r\n<meta property=\"og:type\" content=\"article\" \/>\r\n<meta property=\"og:title\" content=\"How To Split A PDF Using PdfSharp - LDNDeveloper\" \/>\r\n<meta property=\"og:description\" content=\"I recently completed a project which broker a PDF file into multiple files from which I converted to a MS Excel file and ultimately processed the data into a database. This segment is dealing with the portion for splitting a multi-page Adobe PDF file into multiple pages. I mostly do this step, because we will &hellip; Continue reading How To Split A PDF Using PdfSharp\" \/>\r\n<meta property=\"og:url\" content=\"http:\/\/andrewpallant.ca\/wordpress\/how-to-split-a-pdf-using-pdfsharp\/\" \/>\r\n<meta property=\"og:site_name\" content=\"LDNDeveloper\" \/>\r\n<meta property=\"article:published_time\" content=\"2011-04-07T13:01:00+00:00\" \/>\r\n<meta property=\"og:image\" content=\"https:\/\/blogger.googleusercontent.com\/tracker\/4951456985313329413-9061186051406002766?l=softwaredeveloperinlondon.blogspot.com\" \/>\r\n<meta name=\"author\" content=\"andrewpallant\" \/>\r\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\r\n<meta name=\"twitter:creator\" content=\"@ldnDeveloper\" \/>\r\n<meta name=\"twitter:site\" content=\"@LdnDeveloper\" \/>\r\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"andrewpallant\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\r\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"http:\/\/andrewpallant.ca\/wordpress\/how-to-split-a-pdf-using-pdfsharp\/#article\",\"isPartOf\":{\"@id\":\"http:\/\/andrewpallant.ca\/wordpress\/how-to-split-a-pdf-using-pdfsharp\/\"},\"author\":{\"name\":\"andrewpallant\",\"@id\":\"https:\/\/andrewpallant.ca\/wordpress\/#\/schema\/person\/0e7b5e71751000e8f66b17b69ef4ab97\"},\"headline\":\"How To Split A PDF Using PdfSharp\",\"datePublished\":\"2011-04-07T13:01:00+00:00\",\"dateModified\":\"2011-04-07T13:01:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"http:\/\/andrewpallant.ca\/wordpress\/how-to-split-a-pdf-using-pdfsharp\/\"},\"wordCount\":169,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/andrewpallant.ca\/wordpress\/#\/schema\/person\/f6f5bb1ac3e0c5a54a8b5ce35fd67b84\"},\"image\":{\"@id\":\"http:\/\/andrewpallant.ca\/wordpress\/how-to-split-a-pdf-using-pdfsharp\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/blogger.googleusercontent.com\/tracker\/4951456985313329413-9061186051406002766?l=softwaredeveloperinlondon.blogspot.com\",\"articleSection\":[\"C#\",\"PDF\",\"Split\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"http:\/\/andrewpallant.ca\/wordpress\/how-to-split-a-pdf-using-pdfsharp\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"http:\/\/andrewpallant.ca\/wordpress\/how-to-split-a-pdf-using-pdfsharp\/\",\"url\":\"http:\/\/andrewpallant.ca\/wordpress\/how-to-split-a-pdf-using-pdfsharp\/\",\"name\":\"How To Split A PDF Using PdfSharp - LDNDeveloper\",\"isPartOf\":{\"@id\":\"https:\/\/andrewpallant.ca\/wordpress\/#website\"},\"primaryImageOfPage\":{\"@id\":\"http:\/\/andrewpallant.ca\/wordpress\/how-to-split-a-pdf-using-pdfsharp\/#primaryimage\"},\"image\":{\"@id\":\"http:\/\/andrewpallant.ca\/wordpress\/how-to-split-a-pdf-using-pdfsharp\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/blogger.googleusercontent.com\/tracker\/4951456985313329413-9061186051406002766?l=softwaredeveloperinlondon.blogspot.com\",\"datePublished\":\"2011-04-07T13:01:00+00:00\",\"dateModified\":\"2011-04-07T13:01:00+00:00\",\"breadcrumb\":{\"@id\":\"http:\/\/andrewpallant.ca\/wordpress\/how-to-split-a-pdf-using-pdfsharp\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/andrewpallant.ca\/wordpress\/how-to-split-a-pdf-using-pdfsharp\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/andrewpallant.ca\/wordpress\/how-to-split-a-pdf-using-pdfsharp\/#primaryimage\",\"url\":\"https:\/\/blogger.googleusercontent.com\/tracker\/4951456985313329413-9061186051406002766?l=softwaredeveloperinlondon.blogspot.com\",\"contentUrl\":\"https:\/\/blogger.googleusercontent.com\/tracker\/4951456985313329413-9061186051406002766?l=softwaredeveloperinlondon.blogspot.com\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\/\/andrewpallant.ca\/wordpress\/how-to-split-a-pdf-using-pdfsharp\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/andrewpallant.ca\/wordpress\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How To Split A PDF Using PdfSharp\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/andrewpallant.ca\/wordpress\/#website\",\"url\":\"https:\/\/andrewpallant.ca\/wordpress\/\",\"name\":\"LDNDeveloper\",\"description\":\"Learning, Growing and Sharing.\",\"publisher\":{\"@id\":\"https:\/\/andrewpallant.ca\/wordpress\/#\/schema\/person\/f6f5bb1ac3e0c5a54a8b5ce35fd67b84\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/andrewpallant.ca\/wordpress\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/andrewpallant.ca\/wordpress\/#\/schema\/person\/f6f5bb1ac3e0c5a54a8b5ce35fd67b84\",\"name\":\"ldnDeveloper\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/andrewpallant.ca\/wordpress\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/andrewpallant.ca\/wordpress\/wp-content\/uploads\/2017\/05\/cropped-AAEAAQAAAAAAAAXQAAAAJDQxMGRlMzFjLWM4ODctNDk1NC05M2EyLWE1NDNhNTRiZjVlYw-2.jpg\",\"contentUrl\":\"https:\/\/andrewpallant.ca\/wordpress\/wp-content\/uploads\/2017\/05\/cropped-AAEAAQAAAAAAAAXQAAAAJDQxMGRlMzFjLWM4ODctNDk1NC05M2EyLWE1NDNhNTRiZjVlYw-2.jpg\",\"width\":512,\"height\":512,\"caption\":\"ldnDeveloper\"},\"logo\":{\"@id\":\"https:\/\/andrewpallant.ca\/wordpress\/#\/schema\/person\/image\/\"},\"description\":\"Andrew Pallant (@LdnDeveloper) has been a web, database and desktop developer for over 16 years. Andrew has worked on projects that ranged from factory automation to writing business applications. Most recently he has been heavily involved in various forms for ecommerce projects. Over the years Andrew has worn many hats: Project Manager, IT Manager, Lead Developer, Supervisor of Developers and many more - See more at: http:\/\/www.unlatched.com\/#sthash.8DiTkpKy.dpuf\",\"sameAs\":[\"http:\/\/www.andrewpallant.ca\",\"https:\/\/x.com\/LdnDeveloper\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/andrewpallant.ca\/wordpress\/#\/schema\/person\/0e7b5e71751000e8f66b17b69ef4ab97\",\"name\":\"andrewpallant\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/andrewpallant.ca\/wordpress\/#\/schema\/person\/image\/\",\"url\":\"http:\/\/1.gravatar.com\/avatar\/?s=96&d=mm&r=g\",\"contentUrl\":\"http:\/\/1.gravatar.com\/avatar\/?s=96&d=mm&r=g\",\"caption\":\"andrewpallant\"},\"url\":\"http:\/\/andrewpallant.ca\/wordpress\/author\/andrewpallant\/\"}]}<\/script>\r\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How To Split A PDF Using PdfSharp - LDNDeveloper","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"http:\/\/andrewpallant.ca\/wordpress\/how-to-split-a-pdf-using-pdfsharp\/","og_locale":"en_US","og_type":"article","og_title":"How To Split A PDF Using PdfSharp - LDNDeveloper","og_description":"I recently completed a project which broker a PDF file into multiple files from which I converted to a MS Excel file and ultimately processed the data into a database. This segment is dealing with the portion for splitting a multi-page Adobe PDF file into multiple pages. I mostly do this step, because we will &hellip; Continue reading How To Split A PDF Using PdfSharp","og_url":"http:\/\/andrewpallant.ca\/wordpress\/how-to-split-a-pdf-using-pdfsharp\/","og_site_name":"LDNDeveloper","article_published_time":"2011-04-07T13:01:00+00:00","og_image":[{"url":"https:\/\/blogger.googleusercontent.com\/tracker\/4951456985313329413-9061186051406002766?l=softwaredeveloperinlondon.blogspot.com"}],"author":"andrewpallant","twitter_card":"summary_large_image","twitter_creator":"@ldnDeveloper","twitter_site":"@LdnDeveloper","twitter_misc":{"Written by":"andrewpallant","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"http:\/\/andrewpallant.ca\/wordpress\/how-to-split-a-pdf-using-pdfsharp\/#article","isPartOf":{"@id":"http:\/\/andrewpallant.ca\/wordpress\/how-to-split-a-pdf-using-pdfsharp\/"},"author":{"name":"andrewpallant","@id":"https:\/\/andrewpallant.ca\/wordpress\/#\/schema\/person\/0e7b5e71751000e8f66b17b69ef4ab97"},"headline":"How To Split A PDF Using PdfSharp","datePublished":"2011-04-07T13:01:00+00:00","dateModified":"2011-04-07T13:01:00+00:00","mainEntityOfPage":{"@id":"http:\/\/andrewpallant.ca\/wordpress\/how-to-split-a-pdf-using-pdfsharp\/"},"wordCount":169,"commentCount":0,"publisher":{"@id":"https:\/\/andrewpallant.ca\/wordpress\/#\/schema\/person\/f6f5bb1ac3e0c5a54a8b5ce35fd67b84"},"image":{"@id":"http:\/\/andrewpallant.ca\/wordpress\/how-to-split-a-pdf-using-pdfsharp\/#primaryimage"},"thumbnailUrl":"https:\/\/blogger.googleusercontent.com\/tracker\/4951456985313329413-9061186051406002766?l=softwaredeveloperinlondon.blogspot.com","articleSection":["C#","PDF","Split"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["http:\/\/andrewpallant.ca\/wordpress\/how-to-split-a-pdf-using-pdfsharp\/#respond"]}]},{"@type":"WebPage","@id":"http:\/\/andrewpallant.ca\/wordpress\/how-to-split-a-pdf-using-pdfsharp\/","url":"http:\/\/andrewpallant.ca\/wordpress\/how-to-split-a-pdf-using-pdfsharp\/","name":"How To Split A PDF Using PdfSharp - LDNDeveloper","isPartOf":{"@id":"https:\/\/andrewpallant.ca\/wordpress\/#website"},"primaryImageOfPage":{"@id":"http:\/\/andrewpallant.ca\/wordpress\/how-to-split-a-pdf-using-pdfsharp\/#primaryimage"},"image":{"@id":"http:\/\/andrewpallant.ca\/wordpress\/how-to-split-a-pdf-using-pdfsharp\/#primaryimage"},"thumbnailUrl":"https:\/\/blogger.googleusercontent.com\/tracker\/4951456985313329413-9061186051406002766?l=softwaredeveloperinlondon.blogspot.com","datePublished":"2011-04-07T13:01:00+00:00","dateModified":"2011-04-07T13:01:00+00:00","breadcrumb":{"@id":"http:\/\/andrewpallant.ca\/wordpress\/how-to-split-a-pdf-using-pdfsharp\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/andrewpallant.ca\/wordpress\/how-to-split-a-pdf-using-pdfsharp\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/andrewpallant.ca\/wordpress\/how-to-split-a-pdf-using-pdfsharp\/#primaryimage","url":"https:\/\/blogger.googleusercontent.com\/tracker\/4951456985313329413-9061186051406002766?l=softwaredeveloperinlondon.blogspot.com","contentUrl":"https:\/\/blogger.googleusercontent.com\/tracker\/4951456985313329413-9061186051406002766?l=softwaredeveloperinlondon.blogspot.com"},{"@type":"BreadcrumbList","@id":"http:\/\/andrewpallant.ca\/wordpress\/how-to-split-a-pdf-using-pdfsharp\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/andrewpallant.ca\/wordpress\/"},{"@type":"ListItem","position":2,"name":"How To Split A PDF Using PdfSharp"}]},{"@type":"WebSite","@id":"https:\/\/andrewpallant.ca\/wordpress\/#website","url":"https:\/\/andrewpallant.ca\/wordpress\/","name":"LDNDeveloper","description":"Learning, Growing and Sharing.","publisher":{"@id":"https:\/\/andrewpallant.ca\/wordpress\/#\/schema\/person\/f6f5bb1ac3e0c5a54a8b5ce35fd67b84"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/andrewpallant.ca\/wordpress\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/andrewpallant.ca\/wordpress\/#\/schema\/person\/f6f5bb1ac3e0c5a54a8b5ce35fd67b84","name":"ldnDeveloper","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/andrewpallant.ca\/wordpress\/#\/schema\/person\/image\/","url":"https:\/\/andrewpallant.ca\/wordpress\/wp-content\/uploads\/2017\/05\/cropped-AAEAAQAAAAAAAAXQAAAAJDQxMGRlMzFjLWM4ODctNDk1NC05M2EyLWE1NDNhNTRiZjVlYw-2.jpg","contentUrl":"https:\/\/andrewpallant.ca\/wordpress\/wp-content\/uploads\/2017\/05\/cropped-AAEAAQAAAAAAAAXQAAAAJDQxMGRlMzFjLWM4ODctNDk1NC05M2EyLWE1NDNhNTRiZjVlYw-2.jpg","width":512,"height":512,"caption":"ldnDeveloper"},"logo":{"@id":"https:\/\/andrewpallant.ca\/wordpress\/#\/schema\/person\/image\/"},"description":"Andrew Pallant (@LdnDeveloper) has been a web, database and desktop developer for over 16 years. Andrew has worked on projects that ranged from factory automation to writing business applications. Most recently he has been heavily involved in various forms for ecommerce projects. Over the years Andrew has worn many hats: Project Manager, IT Manager, Lead Developer, Supervisor of Developers and many more - See more at: http:\/\/www.unlatched.com\/#sthash.8DiTkpKy.dpuf","sameAs":["http:\/\/www.andrewpallant.ca","https:\/\/x.com\/LdnDeveloper"]},{"@type":"Person","@id":"https:\/\/andrewpallant.ca\/wordpress\/#\/schema\/person\/0e7b5e71751000e8f66b17b69ef4ab97","name":"andrewpallant","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/andrewpallant.ca\/wordpress\/#\/schema\/person\/image\/","url":"http:\/\/1.gravatar.com\/avatar\/?s=96&d=mm&r=g","contentUrl":"http:\/\/1.gravatar.com\/avatar\/?s=96&d=mm&r=g","caption":"andrewpallant"},"url":"http:\/\/andrewpallant.ca\/wordpress\/author\/andrewpallant\/"}]}},"_links":{"self":[{"href":"http:\/\/andrewpallant.ca\/wordpress\/wp-json\/wp\/v2\/posts\/117"}],"collection":[{"href":"http:\/\/andrewpallant.ca\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/andrewpallant.ca\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/andrewpallant.ca\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/andrewpallant.ca\/wordpress\/wp-json\/wp\/v2\/comments?post=117"}],"version-history":[{"count":0,"href":"http:\/\/andrewpallant.ca\/wordpress\/wp-json\/wp\/v2\/posts\/117\/revisions"}],"wp:attachment":[{"href":"http:\/\/andrewpallant.ca\/wordpress\/wp-json\/wp\/v2\/media?parent=117"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/andrewpallant.ca\/wordpress\/wp-json\/wp\/v2\/categories?post=117"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/andrewpallant.ca\/wordpress\/wp-json\/wp\/v2\/tags?post=117"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}