Q: As part of your samples library you have an imposition test where
you basically take 2 pages and arrange them into an a3 landscape page.
I'm trying to do the opposite. The pdf is arranged into book form and
I want to separate the pages into single pages. Which method in the
api is best used for this purpose?
A: To implement this functionality use ElementReader to traverse the
list of elements on the source page. You would also create two target
pages instead of one (e.g. page_left, page_right) and would copy the
elements on the target page depending on the positioning information
(i.e. element.GetBBox(ref rect)). So if the bounding box of the
element intersects the left region of the source page you would write
the element on 'page_left' (using ElementWriter) and if the element is
located on the right side you would copy it to the 'page_right'.
The only difficulty is that content on the 'page_right' should be
shifted horizontally (minus source_page.GetPageWidth()/2.0). There are
couple of options to implement this. One is to surround all content
written on 'page_right' in e_group_begin/end element and to set the
appropriate transform matrix on the inital group element. A possibly
simpler approach is to adjust the media and the crop box on
'page_right' after the content is written to it (e.g. if the original
media box is [0 0 600 700] the new media box is modified to [600 0
1200 700] - for an example of how to implement this media & crop box
shifting please take a look at 'Rect' sample project -www.pdftron.com/
To find more information and sample code related to the topic of
splitting PDF content you may want to search the Knowledge Base using
the following keyword "separate PDF page".