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

Similar Messages

  • 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

  • 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

  • How to download the script data into pdf file

    how to download the script data into pdf file
    i have one option to download the script data to pdf file --->rstxpdft4 program.
    i have one doubt how to use this proogram.or any function module to download the script data to pdf file.
    Thanks and regards,
    Sri.

    Hi      Sri Sai,
    I know one method to convert the sapscript to pdf file :
    first generate a Spool Request for the required Sapscript
    then goto transaction SP01 and copy the generated Spool Request number
    now execute the SAP report RSTXPDFT4
    here enter the copied Spool request number and the target directory into the parameters
    execute the report
    required pdf file will be generated into the target directory
    i hope it will help you out
    Please refer this simple program:
    http://www.sapdevelopment.co.uk/reporting/rep_spooltopdf.htm
    Reward points if found helpful....
    Cheers,
    Eshwar.

  • How can I perform the conversion of pdf files in Cyrillic script to Word files in Cyrillic script. The pdf file is too small for me to read right now. Julyan Watts

    How can I perform the conversion of .pdf files in Cyrillic script to Word files in Cyrillic script. The .pdf file is too small for me to read without a magnifying glass, and the document is more than one thousand pages.

    This answer was not helpful. First of all, I could not find "tech specs"
    anywhere on the Acrobat 11 homepage. And secondly I purchased this software
    for the specific purpose of converting .pdf files to Word. It was only
    after I had completed the purchase that I learnt that Acrobat does not
    permit the conversion of .pdf files in Cyrillic to Word files  in Cyrillic.
    I feel that Acrobat should have provided this crucial information before I
    allowed my credit card to be debited. That is why I  am now asking for my
    money back. But thanks for your attempt to solve my problem, even if it was
    not successful.
    Julyan Watts

  • Script for Place PDF file into a InDesign file

    Hi everyone, i need to import a PDF file into a InDesign document and in order to do this i used scripts found over  the net (e.g. Zanelli's script ecc.) but i tried this solution:
    function(){
        app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;
        var myDocument, myPage;
        if(app.documents.length != 0){
            myDocument = app.activeDocument;
        else{
            alert("No document opened");
            exit();
         if (app.selection[0] == undefined) {
            alert("Select box");
            exit();
         } else {
                var myPDFFile = File.openDialog("Select PDF:");
                if((myPDFFile != "")&&(myPDFFile != null)){
                    myDocument.viewPreferences.rulerOrigin = RulerOrigin.PAGE_ORIGIN;
                    myDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.MILLIMETERS;
                    myDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.MILLIMETERS;   
                    var myData = new Array;
                    myData[0] = app.selection[0].parentPage;
                    myData[1] = app.selection[0].geometricBounds;
                    myData[2] = app.selection[0];
                    myPlacePDF(myDocument, myData, myPDFFile);
        //FUNCTIONS
        function myPlacePDF(myDocument, myData, myPDFFile){
            var myPDFPage;
            var myPage = myData[0];
            var myGeometricBounds = myData[1].toString().split(",");
            app.pdfPlacePreferences.pdfCrop = PDFCrop.cropMedia;
            var myCounter = 1;
            var myBreak = false;
            while(myBreak == false){
                if(myCounter > 1){
                    myPage = myDocument.pages.add(LocationOptions.after, myPage);
                 app.pdfPlacePreferences.pageNumber = myCounter;
                 myRectangle = myPage.rectangles.add(undefined, undefined, undefined, {geometricBounds:[myGeometricBounds[0],myGeometricBounds[1],myGeometricBounds[2],myGeometricBounds[3]]});
                 myRectangle.clearFrameFittingOptions();  
                 myRectangle.frameFittingOptions.fittingOnEmptyFrame = EmptyFrameFittingOptions.PROPORTIONALLY;
                 myRectangle.frameFittingOptions.autoFit = true;
                 myRectangle.frameFittingOptions.fittingAlignment = AnchorPoint.CENTER_ANCHOR;
                 myPDFPage = myRectangle.place(File(myPDFFile), false)[0];           
                 if(myCounter == 1){
                    var myFirstPage = myPDFPage.pdfAttributes.pageNumber;
                else{
                    if(myPDFPage.pdfAttributes.pageNumber == myFirstPage){
                        myPage.remove();
                        myBreak = true;
                myCounter = myCounter + 1;
             myData[2].remove();  
    what i would is, before the script place every single page of PDF file in the document, determine if the same page of the Pdf file is vertical or horizontal, to make the right section for the page.
    Is it possible?
    Thank you

    Moved to scripting forum...

  • 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

  • Script for Portfolio PDF files

    Hi,
    I have a portfolio with several PDF XFA forms inside.
    I want to set up a button so that when the user clicks it the PDF will
    open in a new window (outside of the portfolio); Need help here!
    lock some of the fields; Have this done with .access = "protected";
    save the PDF locally; Done using app.execMenuItem("SaveAs")
    I am having difficulty in scripting a solution like the standard button at the top right of the portfolio window: "Open .pdf file in a new window"
    Any ideas?
    Thanks,
    Niall

    This forum is for scripting questions rather than script requests.
    Please start by reading the following:
    Posting guidelines
    Handy tips for posting to this forum
    How to ask questions in a technical forum
    Rubber duck problem solving
    How to write a bad forum post
    Help Vampires: A Spotter's Guide
    -- Bill Stewart [Bill_Stewart]

Maybe you are looking for

  • Airport extreme and windows vista/8 computers

    Are there any issues with the new airport extreme ac and windows based computers here?

  • Creation of New Page in SAP Script

    Hi Experts, Please advice when will a new page trigger in SAP Script : As per my requirement I need to create a new page for an existing layout and make changes to the second page alone... but this page should be triggered only for a specific conditi

  • How to remove previous Apple TV's from Airplay list in iTunes?

    I replaced two of four AppleTV units today. The new devices installed without a hitch and are humming along. They show up in Airplay, so all is well...almost. Does anyone know how to knock the old Apple TV devices off my Airplay list in iTunes? What

  • Possible to use a field code first name in mail?

    Hi I want to sent a mail to my contacts. And I like to start the mail with Hello <first name of the contact>, Is it possible to do that in this mail software? Kind regards, Rene

  • Performance when executing query on 9iAS Discoverer Plus 1.0.2.2

    Hi, anybody knows when there's information about Discoverer Plus configuration (9iAS release 1) to get a good performance? Because, when I run queries, the response time is not good enough. I have configured the pref.txt file based on the advises of