Splitting PDF pages double page spread (cover or facing) into separate pages.

Q:

We would like to allow the user to decide when his PDF is a double page spread, single page spread, or mixture of both.

in double page spread, every pdf page will be splitted in two, and the very first page of the PDF will be used as the front and back cover of the digital publication.

in mixture of both, every landscape page is splitter in two.

So my question is, how do we handle such cases when converting the PDF to an XOD?

Can I modify my PDFDoc object directly and switch the pages directly on that object? Do I have to create a new PDFDoc and set the page order required to properly handle double page spreads?

My first guest, and since and changing the width and height of the pages, is to create a new PDFDoc object and work on it.

Or do you reckon there’s another solution?

A: There is definitely multiple ways this could be implemented using PDFNet SDK.

The simplest approach I can think of is as follows:

After determining that a given page needs to be split you can duplicate it and change the crop box on the two pages.

Page left = doc.GetPage(i);

doc.InsertPage(i+1, left);

Page right = doc.GetPage(i+1);

left.SetCropBox(new Rect(the area of the left page));

right.SetCropBox(new Rect(the area of the right page));

doc.ToXod();