How to split pdf document properly?

Q:

Could you please tell me why the attached pdf is being turned upside
down
when I split the pages into individual files? My code is as follows:

            PDFNet.Initialize()

            Dim in_doc As PDFDoc = New PDFDoc(input_document)
            in_doc.InitSecurityHandler()

            Dim builder As ElementBuilder = New ElementBuilder
            Dim writer As ElementWriter = New ElementWriter

            Dim page_end As PageIterator = in_doc.PageEnd()
            Dim itr As PageIterator = in_doc.PageBegin()

            While Not itr.Equals(page_end)
                Dim src_page As Page = itr.Current()
                Dim new_doc As PDFDoc = New PDFDoc
                Dim media_box As Rect = New Rect(0, 0,
src_page.GetPageWidth, src_page.GetPageHeight)
                Dim new_page As Page = new_doc.PageCreate(media_box)
                writer.Begin(new_page)
                Dim element As Element = builder.CreateForm(src_page,
new_doc)
                writer.WritePlacedElement(element)
                writer.End()
                new_doc.PagePushBack(new_page)
                Dim pdfPageLocation As String = FileLocation &
ContentId
& "\"
                If Not IO.Directory.Exists(pdfPageLocation) Then
IO.Directory.CreateDirectory(pdfPageLocation)
                Dim pdfOutputFilename As String = pdfPageLocation &
"page" & itr.GetPageNumber & ".pdf"
                new_doc.Save(pdfOutputFilename,
Doc.SaveOptions.e_linearized)
                Dim reader As ElementReader = New ElementReader
                reader.Begin(new_page)
                new_doc.Close()
                'ws.BeginCreatePDFThumbs(pdfOutputFilename,
"application/pdf", smMaxHeight, smMaxWidth, smThumbName, lgMaxHeight,
lgMaxWidth, lgThumbName, False, Nothing, Nothing)
                reader.Begin(itr.Current())
                Dim content As String = GetTextFromPdf(reader,
itr.GetPageNumber)
                reader.End()
                itr.Next()
            End While

            in_doc.Close()
----

A:

Based on your code you are not directly splitting the document, but are
doing PDF imposition.
A simpler (and better) way to split PDF documents is to create a
temporary PDFDoc, copy one (or more) pages to the temporary document,
and then save. This is illustrated in PDFPage same project:
  http://www.pdftron.com/net/samplecode.html#PDFPage

You may also want to read the following section:
  http://www.pdftron.com/net/usermanual.html#copy_pg

You can also tweak your PDF page imposition/placement code to account
for effects of page rotation (i.e. page.GetRotation()) by setting the
transformation matrix
(element.SetTransform(page.GetDefaultMatrix(...))) on form XObject.