Split one page into three

My first project. Need to split 1 page into three pages. Can someone start me down the correct track. I’ve been looking at the examples but so far have not made much progress.

Hi,

How exactly do you plan to do that, by dividing the height by 3 or something else?
What if the split ends up in the middle of some line of text?
Anyway, can you send us a sample PDF file and specify how you would like to split it?

Regards,
Mario

I’m sorry, I cannot provide the document because of sensitive information on the PDF. Let’s just say I want to split the page in 1/2. I see in the examples and API (still digging into this) there are plenty of places you can get the text (or images, etc) but what about the rest of the formatting and what not. Is there not a way to grab everything for say 1/2 the page, Maybe setting the bounds (Original: 0, 0, 1000, 1000; New: 0, 0, 500, 500) and calling a function with those bounds or something like that?

Thanks for the reply.

When you’re iterating through the PdfPage.Content.Elements.All() those elements can be of the following types:

You can refer to the following help page: Content Streams And Resources

Yes, please check the “Reading text from a specific rectangular area” example on the following page:
Read text from PDF files in C# and VB.NET

Does this solve your issue?

Also just as an FYI, here is how you could split the pages:

using(var document = PdfDocument.Load("input.pdf"))
{
    for (int i = 0; i < document.Pages.Count; i += 2)
    {
        var page = document.Pages[i];
        var clonePage = document.Pages.InsertClone(i + 1, page);

        double width = page.Size.Width;
        double height = page.Size.Height;

        page.SetCropBox(0, height / 2, width, height);
        clonePage.SetCropBox(0, 0, width, height / 2);
    }

    document.Save("output.pdf");
}

What this does is it reduces the PdfPage.CropBox, the page’s visible region, by half and it inserts a page clone that has other half of the page as the visible region.

Also if needed, you could go through the pages and remove any element that is outside the bounds of the visible region.

Thanks, this gets me going on the right track.