Split PDF Based on Bookmark

Hi Guys, can anyone help me out on split pdf files Based on Bookmark. I have 300 pages in one pdf and have 50 Bookmarks in that file. Bookmarks are random example 3-9, 10-16,17-23 and keeps on going. So Based on mark i want to separate 50 pdf file.

Thank you,
Gokul.

Hi @gokulvasant ,
In order to use Matches (Regex) you need a consistent pattern within the text.
Can you read the PDF into string and de-identify the result and share?
We can then try to assist with extracting the name. This could then be used a second workflow to split the PDF.
regards,
LNV

Hi @gokulvasant

  1. Read PDF Text (Output: pdfText)
    Input: “path_to_source_pdf.pdf”

  2. Assign (bookmarkMatches)
    TypeArgument: System.Text.RegularExpressions.Match
    Value: System.Text.RegularExpressions.Regex.Matches(pdfText, “\d±\d+”)

  3. For Each (item)
    TypeArgument: System.Text.RegularExpressions.Match
    Values: bookmarkMatches

    3.1 Assign (bookmarkRange)
    Type: String
    Value: item.Value

    3.2 Assign (startPage)
    Type: Int32
    Value: Convert.ToInt32(bookmarkRange.Split("-"c)(0))

    3.3 Assign (endPage)
    Type: Int32
    Value: Convert.ToInt32(bookmarkRange.Split("-"c)(1))

    3.4 Invoke Method (Split PDF)
    Object: UiPath.PDF.Activities.PdfDocument
    MethodName: ExtractPages
    Parameters:
    StartPage: startPage
    EndPage: endPage
    Output: splitPdf (UiPath.PDF.Activities.PdfDocument)

    3.5 Write PDF Text
    Input: splitPdf
    FilePath: "output_folder" & startPage.ToString() & “-” & endPage.ToString() & “.pdf”