I need to be able to split a pdf by bookmark, so each bookmark would become a separate pdf document. Can you offer me some guidance? Thank you
Split PDF
Re: Split PDF
Support · Mar 27, 2009Hello,
We added support for reading outlines from an imported PDF in v5.0 of our product. Please download the evaluation version of DynamicPDF Merger v5.0 for .NET and that will allow you to split the PDF based on bookmarks.
Thanks,
ceTe Software Support Team
Re: Split PDF
Forum member · Mar 27, 2009Ok. Got the eval version working, can you tell me how to split the pdf by bookmark?
Thank you
Re: Split PDF
Support · Mar 27, 2009Hello,
You can read existing bookmarks using the PdfOutlineList class. Following is a sample code for this.
static void Main(string[] args)
{
Document document = OutlinePageNums();
document.Draw( "HelloWorld.pdf" );
Console.ReadLine();
}
public static Document OutlinePageNums()
{
PdfDocument pdfDocument = new PdfDocument(@"C:\Temp\AllPageElements.pdf");
if (pdfDocument.Outlines != null) OutputOutlines(pdfDocument.Outlines);
return new MergeDocument(pdfDocument);
}
public static void OutputOutlines(PdfOutlineList outlines)
{
for (int i = 0; i < outlines.Count; i++)
{
OutputOutline(outlines[i]);
}
}
public static void OutputOutline(PdfOutline outline)
{
Console.WriteLine(outline.Text + " : " + outline.TargetPageNumber);
if (outline.ChildOutlines != null && outline.ChildOutlines.Count > 0) OutputOutlines(outline.ChildOutlines);
}
Thanks,
ceTe Software Support Team.