Split PDF Files by Bookmarks

Can anyone please let me know how do I split PDF Files by bookmark using Java Script.
I am making a Visual Basic utility to read the bookmarks in PDF Files and split them based on the bookmarks. I am able to split the PDF Files by using Arts PDF Split Pro. However since I am already using Adobe Standard, I would like to do it with Adobe itself.
Thus, I pay license for only one software and not two.
Thanks
Rahul

I couldn't find much information online about this myself, but hammered away until it worked. You should easily be able to adjust it for your needs.
My sources:
Adobe IAC Developer Guide
Adobe IAC API Reference
Adobe JS API Reference
Adobe Acrobat and VBA – An Introduction | Karl Heinz Kremer's Ramblings
UtterAccess Discussion Forums > Splitting Pdf Files
Private Sub extractBookmark()
Dim AcroApp As AcroApp, AVDoc As AcroAVDoc, PDDoc As AcroPDDoc, PDBookmark As AcroPDBookmark, AVPageView As AcroAVPageView
Dim newPDF As AcroPDDoc, mergePDF As AcroPDDoc
Dim jso As Object, BookMarkRoot As Object
Dim masterPath As String, testName As String, i As Variant, bookmark As Variant
Dim startN As Integer, endN As Integer, nPages As Integer, totalP As Integer
Set AcroApp = CreateObject("AcroExch.App")
Set AVDoc = CreateObject("AcroExch.AVDoc")
Set PDDoc = CreateObject("AcroExch.PDDoc")
Set PDBookmark = CreateObject("AcroExch.PDBookmark")
masterPath = ActiveWorkbook.Path & "\MasterDocument.pdf"     'Path of the PDF containing the bookmarks to be extracted
AVDoc.Open masterPath, vbNull
Set AVPageView = AVDoc.GetAVPageView
Set PDDoc = AVDoc.GetPDDoc
Set jso = PDDoc.GetJSObject
Set BookMarkRoot = jso.BookMarkRoot
bookmark = jso.BookMarkRoot.Children
totalP = PDDoc.GetNumPages
'Loop through the 10 bookmarks in MasterDocument.pdf and get the starting page # of each. This # has to be changed to the # of bookmarks in your pdf. Or write something to count the bookmarks and use that variable. "productName" is a global variable for my specific project... You'll need to revise this for your purpose.
For i = 0 To 9
    If bookmark(i).Name = productName Then
        PDBookmark.GetByTitle PDDoc, bookmark(i).Name
        PDBookmark.Perform AVDoc
        AcroApp.Exit
        startN = AVPageView.GetPageNum
        If i < 9 Then
            PDBookmark.GetByTitle PDDoc, bookmark(i + 1).Name
            PDBookmark.Perform AVDoc
            AcroApp.Exit
            endN = AVPageView.GetPageNum
            nPages = endN - startN
        Else
            nPages = totalP - startN
        End If
    End If
Next
PDDoc.Close
'This part will also need to be modified. I am inserting the bookmarks into an already made PDF (global variable for me "fName"). You'll want to create a new pdf.
Set newPDF = CreateObject("AcroExch.PDDoc")
Set mergePDF = CreateObject("AcroExch.PDDoc")
newPDF.Open fName & ".pdf"     'This line needs changing for your purpose. Probably could be.... newPDF.Create
mergePDF.Open masterPath
newPDF.InsertPages 0, mergePDF, startN, nPages, 0
newPDF.Save PDSaveFull, fName & ".pdf"
newPDF.Close
mergePDF.Close
End Sub

Similar Messages

  • Script to Split PDF files on Bookmarks

    I'm totally new to Java scripting.  What I'm looking for is a script I can run from batch processing with professional that will look at a collection files in s directory and split ech one of them on their bookmarks into smaller files.
    The bookmarks are all based on the page so it is possible to use the bookmark object's "execute" method to execute the bookmark action and pickup the page number.
    I read that last part somewhere. If someone can give me a reference to a thread or just some code to get me started that would help. Thanks,
    Josh

    5 years later... hopefully this helps someone out there.
    I couldn't find much information online about this myself, but hammered away until it worked. My code is for a slightly different purpose, but you should easily be able to adjust it for your needs.
    My sources:
    Adobe IAC Developer Guide
    Adobe IAC API Reference
    Adobe JS API Reference
    Adobe Acrobat and VBA – An Introduction | Karl Heinz Kremer's Ramblings
    UtterAccess Discussion Forums > Splitting Pdf Files
    Private Sub extractBookmark()
    Dim AcroApp As AcroApp, AVDoc As AcroAVDoc, PDDoc As AcroPDDoc, PDBookmark As AcroPDBookmark, AVPageView As AcroAVPageView
    Dim newPDF As AcroPDDoc, mergePDF As AcroPDDoc
    Dim jso As Object, BookMarkRoot As Object
    Dim masterPath As String, testName As String, i As Variant, bookmark As Variant
    Dim startN As Integer, endN As Integer, nPages As Integer, totalP As Integer
    Set AcroApp = CreateObject("AcroExch.App")
    Set AVDoc = CreateObject("AcroExch.AVDoc")
    Set PDDoc = CreateObject("AcroExch.PDDoc")
    Set PDBookmark = CreateObject("AcroExch.PDBookmark")
    masterPath = ActiveWorkbook.Path & "\MasterDocument.pdf"     'Path of the PDF containing the bookmarks to be extracted
    AVDoc.Open masterPath, vbNull
    Set AVPageView = AVDoc.GetAVPageView
    Set PDDoc = AVDoc.GetPDDoc
    Set jso = PDDoc.GetJSObject
    Set BookMarkRoot = jso.BookMarkRoot
    bookmark = jso.BookMarkRoot.Children
    totalP = PDDoc.GetNumPages
    'Loop through the 10 bookmarks in MasterDocument.pdf and get the starting page # of each. This # has to be changed to the # of bookmarks in your pdf. Or write something to count the bookmarks and use that variable. "productName" is a global variable for my specific project... You'll need to revise this for your purpose.
    For i = 0 To 9
        If bookmark(i).Name = productName Then
            PDBookmark.GetByTitle PDDoc, bookmark(i).Name
            PDBookmark.Perform AVDoc
            AcroApp.Exit
            startN = AVPageView.GetPageNum
            If i < 9 Then
                PDBookmark.GetByTitle PDDoc, bookmark(i + 1).Name
                PDBookmark.Perform AVDoc
                AcroApp.Exit
                endN = AVPageView.GetPageNum
                nPages = endN - startN
            Else
                nPages = totalP - startN
            End If
        End If
    Next
    PDDoc.Close
    'This part will also need to be modified. I am inserting the bookmarks into an already made PDF (global variable for me "fName"). You'll want to create a new pdf.
    Set newPDF = CreateObject("AcroExch.PDDoc")
    Set mergePDF = CreateObject("AcroExch.PDDoc")
    newPDF.Open fName & ".pdf"     'This line needs changing for your purpose. Probably could be.... newPDF.Create
    mergePDF.Open masterPath
    newPDF.InsertPages 0, mergePDF, startN, nPages, 0
    newPDF.Save PDSaveFull, fName & ".pdf"
    newPDF.Close
    mergePDF.Close
    End Sub

  • How to split PDF file by pages

    Is there any programming way to split PDF into pages, say one PDF file per page or specify page range to split PDF file?
    Thanks for your help.

    Yes it does. It disassembles pdf1 by extracting pages 1-3 and disassembles pdf2 by extracting pages 4-5. Then re-assembles the two subsets into a new PDF.
    You could extract page1 from pdf1 only and create a pdf, then page2 of pdf1 into a different PDF using something similar to:
    <?xml version="1.0" encoding="UTF-8"?>
    <DDX xmlns="http://ns.adobe.com/DDX/1.0/">
    <PDF result="Final.pdf">
         <PDF source="PDF1.pdf" pages="1"/>
    </PDF>
    <PDF result="Final2.pdf">
          <PDF source="PDF1.pdf" pages="2"/>
    </PDF>
    </DDX>
    You can also use the  PDFFromBookmarks tag to generate a new document for each level 1 bookmark created in a PDF.
    <PDFsFromBookmarks prefix="stmt">
         <PDF source="doc1.pdf"/>
    </PDFsFromBookmarks>
    You can get more info at http://livedocs.adobe.com/livecycle/8.2/ddxRef/000640.html
    Jasmin

  • How to print an excel file (2010 version) with multiple tabs into a pdf file with bookmarks (acrobat 9). I was able to do this easily using excel (2007 version).

    Recently I got a new laptop, with excel 2010 version and acrobat 9 standard.
    I could no longer print (save as) an excel file with multiple tabs into a pdf file with bookmarks.
    My old computer has excel 2007 version and acrobat 9 standard.
    Print an excel file into pdf with bookmarks was a piece of cake.
    Both machine has the same add-in -- Acrobat PDFMaker Office COM addin
    Thanks if anyone could help me with this.
        Tom

    You need to upgrade Acrobat to a newer version.
    On Thu, Oct 30, 2014 at 4:12 PM, excel-pdf-bookmarks <

  • How to split pdf files also how to downsize a pdf file?

    how to split pdf files also how to downsize a pdf file?

    Hi Ali,
    If the PDF file you're starting with is larger than 100MB, ExportPDF won't be able to convert it.
    To convert a file of that size and to create separate files, you'll need Adobe Acrobat.  You'd need Acrobat to divide the file into smaller chunks for ExportPDF anyhow, so Acrobat is probably the best solution for you.  You can learn more about Acrobat here: http://www.adobe.com/products/acrobat.html
    Kindest regards, Stacy

  • PDF Files with bookmarks open in iPad iBooks without the bookmarks.

    PDF Files created with Adobe Acrobat or other PDF file creating software open in iPad iBooks with the Bookmarks.  How do you access those.

    since iBooks doesn't have an "Open In" button or feature, how do I access PDF's in iBooks with Adobe Reader?

  • Insert a PDF document to a PDF file at bookmark javascript?

    I have a PDF file with several bookmarks.
    I want each bookmark, when clicked to run Javascript that prompts the user to select a file, weather it be a PDF file or word file. Once the file is selected, it inserts the file into the existing PDF document at the bookmark.
    Can anyone give me some advice or code to make this happen?
    Greatly appreciated!

    Maybe it will help you to understand if I describe what I am trying to do.
    I need to create a template for a department at work.
    They receive several documents and need to basically merge them into one PDF file in a certain order. For example, Contract, Pay Plan, Signature
    The order changes depending on the type of customer, which is why a template that prompts to insert a PDF file (not an attachment) into the template at the bookmarks makes sense to me. This would make it so there would be no errors in the process and the people doing this work wouldn't have to remember what order for each type of customer.

  • Open PDF file with Bookmarks Showing

    Hi - forgive me if this is the wrong forum, but I can't find a topic called "how to use Acrobat"
    I need to create a PDF that will open in Acrobat Reader with the bookmarks displayed. The file will be distributed as a PDF and will not be associated with a web page.
    And, if everything was perfect, I'd like that file to be open at 100% instead of the current 150%.
    Is there a way to set this up?
    Karen

    Good morning.  I was researching this same issue and found a solution for Adobe 9 Standard.  I went into File > Properties > Inital View tab.  On the first line, it says "Navigation tab:"  I selected "Bookmarks Panel and Page" from the drop-down selection.  Save your file, of course.  Now, whenever someone opens this file, the bookmarks will show on the left side of the page and the document to the right. 

  • Split pdf file

    Anyone know how to split a pdf with automator or applescript..
    I want to be able to get one file out of every 2. page of the original file.
    Like this..
    Original pdf file may contain 10 pages.. I want the result to be 5 files with two pages in each file.
    File one contains page 1 and 2 of the original, file two contains page 3 and 4 etc..
    Not enought to split by even or odd pages as i need page 1 and 2 in the same file..

    You need Adobe Acrobat to do so. Splitting a document is not possible with Adobe Reader.

  • Splitting pdf files

    how can pdf files be split, what is required and what are the steps?

    Furthermore, emailing e-documents is never a good idea; they can get damaged, misdirected, or lost in the process.
    Far better use a file sharing service like Acrobat.com, Dropbox, Google Drive, etc., then send the download link via email.

  • Splitting PDF files for iPhone

    Is there any way to split large, protected pdf files to work with Quickoffice on the iPhone? Quickoffice has no "go to" page function making it very difficult to read a large document. I don't want to change anything in the file, just put the file into bite size pieces.
    Thanks

    I've done this using a program called PDFKey Pro. It's a paid app, though you may also find free alternatives.
    http://www.macupdate.com/info.php/id/17114/pdfkey-pro

  • Reader XI Version 11.0.07 running on Windows XP SP2/3 -- can't split .pdf file ; Tools -- Pages menu not visible/available

    Hi , Folks
    My ( free ) download of Adobe Reader XI doesn't permit me to split a ( scanned )  .pdf file into two separate .pdf files , as I would like .
    The on-line Help advises me to go into Tools --> Pages to do this .
    But my Tools menu does not have Pages , within it .
    Do I need to download an older ( free ) revision ; i.e., Adobe Reader X ?
                            Please advise ,
                                  Peter

    No, you need to purchase Acrobat to be able to do that. The free Reader can't perform such editing tasks.

  • READER XI - How to open PDF files with bookmark pane minimized (hidden)

    In Reader XI, cannot make the Bookmark Pane minimized (hidden) by default, and it opens for many PDF files that do not need it.  I want to locate a setting or option that allows opening of PDFs without the Bookmark Pane opening.

    "Google" is a search engine (website) and NOT (repeat: NOT) a PDF viewer. It can't and won't open PDFs in any real or imaginable way.
    Firefox added their own proprietary PDF viewer with version 20 - they're on 21 now. I'll be the first to admit "it sucks". You CAN'T fill in PDF forms with it, and you can't email them from the page like with Opera, Safari or Chrome (which use the reader plug-in still).
    Unfortunately, the ONLY option you have now that they've added it and killed the ability for the Reader plug-in to work with Firefox, is Tools>Options>Applications - select Portable Document Format(PDF) and choose "Use Adobe Reader (Default)". What that will do is FORCE Firefox to download the PDF instead of opening it in their terrible PDF viewer in the browser window.
    Or... use one of the other browsers I mentioned. They're all free.

  • Wont display pdf files from bookmarked sites

    I've upgraded to Firefox 4 and now when I go to some of bookmarked sites that have attached PDF files, I'm unable to view those PDF files. I didn't have this problem with Firefox 3.5, however, per your suggestion, I've downloaded Firefox 4 to avoid any possible security issues. Any possible solutions, or is it possible to revert to using 3.5 w/0 any security issues?

    Back up all data.
    Quit Safari. In the Finder, select Go ▹ Go to Folder... from the menu bar, or press the key combination shift-command-G. Copy the line of text below into the box that opens, and press return:
    /Library/Internet Plug-ins
    From the folder that opens, remove any items that have the letters “PDF” in the name. You may be prompted for your login password. Then launch Safari and test.
    If you still have the issue, repeat with this line:
    ~/Library/Internet Plug-ins
    If you don’t like the results of this procedure, restore the items from the backup you made before you started. Relaunch Safari again.

  • Splitting PDFs while preserving bookmarks

    I have a long PDF that i put mutliple levels of bookmarks into but now it is too large for me to upload. If I split it by the top level bookmarks I lose all the other bookmarks in the new file. Is there a way to do this without having to rebookmark the new files?

    You can do it by deleting the pages you don't want in each file, which will preserve the bookmarks structure.
    This process could also be automated using a script.

Maybe you are looking for

  • Issue with Game Center Accounts

    I believe this was posted previously by richardgraham90, but i am having an issue with game center. It seems that i somehow have two active game center accounts under one apple ID. I have been using one ever since i got the itouch 4, and just a few w

  • Check file name format

    1)I have to check if a file exists else terminate the job 2)if file exists then check the format and if format is incorrect, give the message. i.e, i need to check whether filename is having correct format. for e.g: ABCDddmmyy.txt Every file in folde

  • Failed iPhone software update to 2.0, failed restore with error 1604

    I downloaded the latest iTunes 7.7 and upon "Check for Update", I was notified that iPhone firmware 2.0 for the 2G iPhone was out. I downloaded the firmware, synced/backed up settings, and then rebooted. Then something went wrong... I restarted iTune

  • Genric extracor -data source

    Hi friends,    when the data source does nt support delta upload then we go for generic extractor.am i right?   can u pls tell me few data sources ,which does nt support delta update thanks in advance. regards mano

  • The Application Installer quit unexpectedly error when reinstalling Safari

    My Safari no longer functions as it was removed from my Powerbook and I no longer have the installation disk.   I am attempting to manually install Safari3.2.3Ti.dmg.  The installation stops and I receive "The Application Installer quit unexpectedly"