How do I cut PDF pages?

Q: One of our clients provides us with PDF files in which each page
contains the Front and Back; we are currently using another software
to cut/split PDF pages but it is very slow when we get file with 3000+
pages and it does not work relaibly. Can I use PDFNet (http:// to cut PDF pages?
A: You can use the following code snippet as a starting point:

// C# sample to cut/split PDF pages (VB, JAVA, C/C++ is along the same

PDFDoc doc = new PDFDoc("my.pdf");

int pgnum = doc.GetPageCount();
for (int i = 1; i <= pgnum; ++i)
  // Clone the page
  PageIterator itr = doc.GetPageIterator(i * 2 - 1);
  Page pg = itr.Current();
  doc.PageInsert(itr, pg);

  // Adjust the crop box on the first page
  Rect box = pg.GetCropBox();
  box.x2 = (box.x1 + box.x2) / 2;

  // Adjust the crop box on the second page
  pg = doc.GetPage(i * 2);
  box = pg.GetCropBox();
  box.x1 = (box.x1 + box.x2) / 2;
doc.Save("out.pdf", 0);

To download full sample code:

A relevant sample in PDFNet SDK i RectTest sample: