# How to split existing pages based on their content?

**URL:** <https://community.apryse.com/t/how-to-split-existing-pages-based-on-their-content/300>\
**Category:** Apryse SDK\
**Created:** [April 27, 2007, 7:59pm UTC](https://community.apryse.com/t/how-to-split-existing-pages-based-on-their-content/300 "2007-04-27T19:59:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aaron\_Gravesdale](https://community.apryse.com/letter_avatar_proxy/v4/letter/a/ba8739/32.png) [@Aaron\_Gravesdale](https://community.apryse.com/u/Aaron_Gravesdale)\
**Post date:** [April 27, 2007, 7:59pm UTC](https://community.apryse.com/t/how-to-split-existing-pages-based-on-their-content/300/1 "2007-04-27T19:59:49Z")

</div>

Q:  
Can you give me some starting pointers to perform the following:

The flow is as follows:

1.LOAD/OPEN PDF  
2.GET PAGE COUNT  
While count \< = page count  
&nbsp;&nbsp;3.READ TOP REGION OF PAGE TO TEXT  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;when I find the text that indicates new page  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4.SPLIT OUT NEW PDF (SOURCE, NEW, FROM PAGE, TO PAGE)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;5.CONVERT NEW.PDF TO NEW.TIFF  
&nbsp;&nbsp;&nbsp;6.MOVE TO NEXT PAGE  
End While  
---  
A:

> 1.LOAD/OPEN PDF  
> 2.GET PAGE COUNT

PDFNet.Initialize();  
// See [http://pdftron.com/net/faq.html#pdfnet\_res](http://pdftron.com/net/faq.html#pdfnet_res)  
PDFNet.SetResourcesPath("c:/myapp/pdfnet.res");

PDFDoc doc = new PDFDoc(input\_path + "newsletter.pdf");  
doc.InitSecurityHandler();  
int pgnum = doc.GetPagesCount();

> 3.READ TOP REGION OF PAGE TO TEXT  
> &nbsp;&nbsp;&nbsp;when I find the text that indicates new page

As a starting point, you may want to take a look at TextExtract  
([http://pdftron.com/net/samplecode.html#TextExtract](http://pdftron.com/net/samplecode.html#TextExtract)) sample project.

So you could determine the splitting point using ElementReader and  
Element interface.

To split the content on an existing page into multiple pages you can  
use the same approach illustrated in ElementEdit sample:  
[http://pdftron.com/net/samplecode.html#ElementEdit](http://pdftron.com/net/samplecode.html#ElementEdit).

ElementEdit sample modifies content of existing page, but you can  
simply copy page element on several output pages without any changes  
to their graphics state.

In case you don't need to split the content in the page, but you  
simply want to split pages on the document level you can follow the  
approach used in PDFPage sample project ([http://pdftron.com/net/](http://pdftron.com/net/)  
samplecode.html#PDFPage and [http://pdftron.com/net/usermanual.html#page\_manip](http://pdftron.com/net/usermanual.html#page_manip)).

> 5.CONVERT NEW.PDF TO NEW.TIFF

You can convert newly created pages to TIFF and other image formats  
using PDFDraw class (please see [http://pdftron.com/net/usermanual.html#PDFDraw](http://pdftron.com/net/usermanual.html#PDFDraw)  
sample project). All of this can be done without creating any  
intermediate or temporary files.
