Split/Extract pages by bookmarks

I have created a script which will successfully split the pdf at the first bookmark.
I need for the script to split all bookmarks from the pdf. 
I have modifed the script but the console reports the following error:
TypeError: bookmarkRoot.children[i] is undefined
Can someone please provide assistance to modify the script to split all bookmarks from the pdf?
Script to split the pdf at the first bookmark - this works!
if (this.bookmarkRoot.children!=null)
var bm = bookmarkRoot.children[0].execute();
var bmname = bookmarkRoot.children[0].name;
this.extractPages({nStart:bm, cPath: "/C/Temp/"+bmname+".pdf"});
Script to split all bookmarks in the pdf - this does not work!
if (this.bookmarkRoot.children!=null)
for (var i=0; i < this.bookmarkRoot.children.length; i++)
var bm = bookmarkRoot.children[i].execute();
var bmname = bookmarkRoot.children[i].name;
this.extractPages({nStart:bm, cPath: "/C/Temp/"+bmname+".pdf"});
Thank you!

Thank you for your advice.
I have placed the curly brackets after the "for command" and the script will rename the split files as the bookmark names.
There is a problem with the var bm = this.bookmarkRoot.children[i].execute(); part of the script.
The script splits all the bookmarks at page 1 and not the correct page associated with the bookmark names.
My thoughts are that the bookmark execute command may need to be recursive to work??
The script has been modified for recursive and the console reports back as undefined and does not split the pdf at the bookmarks.
Can you please advise if I am going in the right direction in getting the file to split correctly:
function splitBookmarks (bm,  nLevel)
if (bm.children!=null)
for (var i=0; i < bm.children.length; i++)
var bmd = splitBookmarks(bm.children[i], nLevel + 1);
var bme = bmd.execute();
var bmname =bm.children[i].name;
this.extractPages({nStart:bme, cPath: "/C/Temp/"+ bmname +".pdf"});
Thanks!

Similar Messages

  • Extract Pages- and the Split- not doing what I expect them to

    I have a document created in Illustrator (CS4) which has multiple artboards. I want it split into multiple documents, one art board—> one document with only that artwork. When I use the Extract PAges… and the Split… comands to generate multiple documents, I get the multiple docs (same number of docs created as pages in original doc).
    Only thing is every doc has all the artboards and all the artwork as the original doc. I could understand all the artwork being there but all the artboards also?? What's going on?
    Appreciate any pointers on this.
    Trying to write a JSX to run in AI but struggling so far. Thread for AI solution started here: AS) export single page PDFs from multi-artboards

    I don't expect mind reading but I'l settle for careful reading
    I tried to explain how pages and artboards are qualitatively different objects only to be told they are the same thing and that's all I needed to say.
    I tried to explain that opening the very same file in Illustrator showed a lot more objects than it did in Acrobat. You probably don't remember because you breezed over something that you didn't think you needed to know because you were, at each stage, a step ahead of me (slow down already!).
    From my second post:
    I can't remember if Splitting gave enumerate files or the one file but either way ALL the artwork was in the enumerate files if they got made [.…] I ended up saving as CS3 .ai files which gives a Save artboards to seperate files option and, unlike the artboard range option on Save As PDF, it actually works.
    From my third post
    An artboard is not a page as far as Acrobat and Illustrator apps are concerned. I was trying to highlight the distinctly different way the two apps handle them. I can watch a one page with just one shape document in Acrobat become a 20 artboard, 40+ objects layout in Illustrator. Same document interpreted as one Page in Acrobat and 23 artboards in AI.
    I was on this forum because even a manual Document Menu> Split… command is not doing what I expected with the AI generated 23pp PDF file. I expected the 23 individual 'artboards' and content to each make a separate file.
    Thom Parker wrote:
    I don't remember you mentioning that you re-imported the PDF files into Illustrator.  This is an important detail. You also posted to an Acrobat scripting forum and never said you were not interested in an Acrobat Script.  You also never explained the problem you were seeing.  You were never clear.
    Covered that but note Illustrator doesn't import PDF files. .ai .eps and .pdf are all native files for Illustrator and just open, sometimes with an additional dialogue to choose a page from multiple pages. It imports .dwg, .svg and that sort of thing relying on translator plugins. This is the fourth time I'm saying I should have posted in Acrobat Win or Mac not scripting, apologies I was scripting when I made OP and probably frustrated. You were more clear it's true, clearly ignoring what I was getting at in each post re artboard cf. page objects.
    You see, in a PDF file each page has it's own content stream, i.e., a stream of vector graphics operators.  Graphics can be drawn anywhere in the coordinate space, but the page view is clipped by a crop rectangle.  So graphics can exist in the stream, but never be visible to the user because they are outside the crop.  I get the impression that in Illustrator the Artboards all exist in a single coordinate space? And that the conversion to PDF places this entire coordinate space into a single content stream. Then each page would be a different crop of the same content stream.  If this is the case then I believe there are PDF optimization operations in Acrobat that would fix your problem by removing all content outside the crop. 
    Yeah I've hacked lots of PDF files in AI. They use more than one clipping rect per page from memory. Correct, the artboards are defined in a single co-ord space it would seem — artboards are discretely and independently located on the document canvas and can even overlap each other. Yes those operations might work, I never though of that, I came across an Illustrator based solution early on in this thread. There's no conversion going on in Acrobat though I think, the file stays native PDF from AI to Acrobat and back to AI. As I've noted it's the way Acrobat displays or parses the data that in effect hides all the 'off-page' objects but open the same file in AI and it's all still there. 
    You know, we can't read minds, you actually have to explain what it is you need.
    I didn't know it, but I needed to get a confirmation on the artboardRange property bug in Illustrator CS4 and/or a confirmation that artboards are not treated as page objects, and I ended up having to lecture you on something you may have no interest in, sorry if I've been a pain. This is part of bigger bug elsewhere that I've been trying to get resolved or around on and off for a month. Every turn another bug, it gets confusing and frustrating at times

  • Extract Pages- and Split- Commands

    I have a document created in Illustrator (CS4) which has multiple artboards. I want it split into multiple documents, one art board—> one document with only that artwork. When I use the Extract PAges… and the Split… comands to generate multiple documents, I get the multiple docs (same number of docs created as pages in original doc).
    Only thing is every doc has all the artboards and all the artwork as the original doc. I could understand all the artwork being there but all the artboards also?? What's going on?
    Appreciate any pointers on this.
    Trying to write a JSX to run in AI but struggling so far.

    Maybe you should invest in Acrobat...
    On Wed, Aug 20, 2014 at 11:28 AM, methebeachbum <[email protected]>

  • Another "extract pages" and "split" PDF question

    I have subscribed adobe's convert to pdf and I was happy with convert function until I found out that I can't upload nor convert 59 MB of a file. Tried several methods, non of them worked. I decided to split the pdf or extract pages that I want it to be converted but guess what? There is no such function. Even if there is, it is very well hidden.
    Can someone please explain me how the heck do I extract pages or split the document in parts? Non of the online free splitters work on my file.

    Maybe you should invest in Acrobat...
    On Wed, Aug 20, 2014 at 11:28 AM, methebeachbum <[email protected]>

  • 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 do I split each page into a PDF and name them after a line of text on the split page?

    All,
    I am running a report that is creating hundreds of letters to be sent to customers.  When I run the report it creates one large PDF (one letter = one page).  To help with a specific business solution I need to split each page into an individual PDF.  I know I can extract the pages using the extraction tool.  I have also been able to duplicate this from the Javascript console, but only with generic names.  The problem is that I need each PDF named after the customer's account number.  The account number is listed on the page that I am extracting, but I am having a hard time parsining the text on the pages to find it.
    I need to be able to turn each page into a seperate PDF and then rename that PDF to match the account number list on the page.
    The account number, is of course, different for every customer and has varied prefixes.  The line of text that I need to read starts like this:
    Account Number#: NJA00001
    I need to just pull the NJA00001.
    I would really love to automate this process.
    Can you help me with this?  Thanks in advance.
    PS: I am a little rusty on my Javascript, its been a couple years.

    This can probably be achieved with a custom-made script, but it's not possible to know for sure before seeing some sample files.

  • Button to extract pages

    myexportFunc = app.trustedFunction(function(){
    ////Get Naming Convention
    var cRtn = app.response('Enter naming convention for section:');
    ////Save to current location. Get path of current doc
    var testing = this.path;
    var test = testing.split('/');
    var thepath = '';
        for (i = 0; test.length -2 >= i; i++)
              thepath =  thepath + test[i] + '/';
    ////Extract Pages
        for (p = 1; this.numPages >= p; p++)
    var pgno = p;
    ///pgno = pgno + 1;
                        if (pgno < 10) {
                                  var pgno = '0' + pgno;
                        } else {
                                  var pgno = pgno;
              var newname = cRtn + pgno + '.pdf';
                this.extractPages({
                             nStart: p,
                             cPath: thepath + newname
    var myDoc = app.newDoc();
              // import icon (20x20 pixels) from the file specified
              myDoc.importIcon("myIcon", "/adsROP/1 COMMON/Application Settings/Scripts/assets/Untitled-1.pdf", 0);
              // convert the icon to a stream.
              oIcon = util.iconStreamFromIcon(myDoc.getIcon("myIcon"));
              // close the doc now that we have grabbed the icon stream
              myDoc.closeDoc(true);
              // add a toolbutton
              app.addToolButton({
                        cName: "myToolButton",
                        cLabel: "Extract Pages",
                     oIcon: oIcon,
                        cExec: "myexportFunc()",
                        cTooltext: 'Extract Pages',
                        cEnable: true,
                        nPos: 0
    The button successfully is added. The function fires, etc....
    The extract pages function run alone works as is.
    I get the following error: 
    RangeError: Invalid argument value.
    Doc.extractPages:30:Doc 54d3a00myToolButton:Exec

    I get the error:
    RangeError: Invalid argument value.
    Doc.extractPages:30:Doc 54d3a00myToolButton:Exec
    I am running this from the console currently, but I did need to make the extract pages to be privileged.
    myexportFunc = app.trustedFunction(function(){
    ////Get Naming Convention
    var cRtn = app.response('Enter naming convention for section:');
    ////Save to current location. Get path of current doc
    var testing = this.path;
    var test = testing.split('/');
    var thepath = '';
        for (i = 0; test.length -2 >= i; i++)
              thepath =  thepath + test[i] + '/';
    ////Extract Pages
        for (p = 0; this.numPages >= p; p++)
    var pgno = p + 1;
                        if (pgno < 10) {
                                  var pgno = '0' + pgno;
                        } else {
                                  var pgno = pgno;
              var newname = cRtn + pgno + '.pdf';
    app.beginPriv();
                this.extractPages({
                             nStart: p,
                             cPath: thepath + newname
    app.endPriv();
    var myDoc = app.newDoc();
              // import icon (20x20 pixels) from the file specified
              myDoc.importIcon("myIcon", "/adsROP/1 COMMON/Application Settings/Scripts/assets/Untitled-1.pdf", 0);
              // convert the icon to a stream.
              oIcon = util.iconStreamFromIcon(myDoc.getIcon("myIcon"));
              // close the doc now that we have grabbed the icon stream
              myDoc.closeDoc(true);
              // add a toolbutton
              app.addToolButton({
                        cName: "myToolButton",
                        cLabel: "Extract Pages",
                     oIcon: oIcon,
                        cExec: "myexportFunc()",
                        cTooltext: 'Extract Pages',
                        cEnable: true,
                        nPos: 0
    This works. I just need to adjust the for loop to end at the last page rather than trying to go on to a page that does not exist.

  • Extract pages in same PDF version as original document

    That's it!
    It is annoying to extract pages from a PDF 1.3 doc. and have the resulting files be in PDF 1.6.
    It is also somewhat strange that the format is not even the native 1.7 format from Acrobat 8.1.1, which I'm using...
    The most useful implementation would be to have a choice of output format with the original doc. format set as default.
    I would also like a keyboard shorcut for the Extract feature, as requested in other posts...
    /eac

    Optimal application behaviour is subjective based on the user's needs.
    My request stems from needing to split PDF documents into single-page documents without altering the format.
    Adding a preference setting for the default behaviour would allow all users to have it their way: options to preserve format or save as specific format.
    In addition, the save dialogue should contain an option to select the desired format, with the default being set from the preference setting.
    /eac

  • Firefox allows me to add some pages as bookmarks and not others. For pages that don't work: when I click the star, it turns blue when I click, then goes back to being empty.

    Last night I finally sat down to learn how to use Bookmarks. I had no problem creating and organizing bookmarks, but there are some pages that I cannot bookmark. One, for example, is the Gmail log-in page, which I use multiple times a day. I type in www.gmail.com, which routes me to a longer URL and the log-in page. When I click the star to make this page a bookmark, it won't work. I've also tried using the menu option "Bookmark This Page," which also doesn't work for this website. It's seems to be hit and miss as to when Firefox will allow me to bookmark a page and when it won't. I've had no problem adding many other pages; it just seems that with a handful of them I run into this issue.
    I've tried closing Firefox and re-opening, which doesn't help, but that is about the extent of my troubleshooting attempts. This problem has been an issue for me for a couple of years and through several versions of Firefox. (I think I am currently running the most recent version.) It actually led me to believe early on that either Firefox Bookmarks didn't work or I just didn't have the time to figure it out. So since I've been using Firefox I have been repeatedly typing the names of my most frequented sites. I finally took time to sit down with it again last night and have found that Bookmarks will be a huge help. If I could only get ALL of my favorite pages to work...

    None of the stuff in " http://kb.mozillazine.org/Locked_or_damaged_places.sqlite " helps. I have tried and tried and I have even wipe the computer clean still didn't help. I got the same problem as he/she has got in the first posted. Can add some web pages but not all the web pages I want.. I should have never updated to 3.6.13... That's when it all started for me, from that version..... Now Version 3.6.14 is out, I was hoping the version 3.6.14 might would fix the problem wrong again....
    Funny thing is i can not even Bookmark Firefox.com!!!!!...lol
    So any ideas on how to fix it other than the link giving would help.
    Thanks.

  • ?split-by-page-break:?

    Hi
    i am trying to use the command <?split-by-page-break:?> to skip a page in my XmlPublisher report if a certain
    condition is true.
    The Command doesn't work.( it works only in a loop...)
    I tried the commands
    <xsl:attribute name="break-before">page</xsl:attribute></xsl:if>
    or
    <xsl:attribute name="break-after" xdofo:ctx="incontext">page</xsl:attribute>
    still unsuccessfuly...
    I tried <?if:...> word-page-break <?end if?> .
    It creates an empty page if i dont want to skip the page and the page is the last page.
    If there was an OR or AND operands in the Bi Publisher IF , i might have solved it..
    Is there OR or And opernads in Bi Publisher IF ?
    how can i had a dynamic page-break?
    Thanks

    Conjunction and disjunction are available in "if", but make sure they are in lower case: and or

  • How to Split the Page in Numbers

    I took a quick test drive on Numbers and stopped when I could not find the
    the little tab in the upper right corner of an Excel worksheet that lets you
    spilt the page for ease of working a page.
    Help..... how do you split the page for ease of working and reading in Numbers?
    aRKay

    I am working on making the transition to Numbers, and for the most part love the flexibility of the new program. However, this lack of being able to open a new window in the same sheet is frustrating. Let me give you my situation, and if anyone has any thoughts I'd be most appreciative!
    I run a competition that has 30+ competitors all needing separate scoresheets. Those overall scores for each group need to be summarized on a separate page. In Excel, I had a separate sheet for each competitor, and then I linked cells from those sheets to the summary sheet. This was made easy as I could have one window open with the individual competitors sheet, and another window open with the summary sheet.
    When I tried to implement this in Numbers (admittedly I approached the problem with an Excel mindset) I set up my separate sheets for each competitor, and now that I'm in the stage of making the summary sheets, I need to click on the cell in the summary sheet, find the referenced sheet in the sheet list, click on it, find the proper cell, click on it... There are over a dozen references per sheet. I have not been able to find a satisfactory work around in Numbers.
    Even if I set up each individual competitor as it's own table, and the summary as it's own table, all in the same sheet, I would still not be able to view both the summary and the competitor tables at the same time without scrolling back and forth. I'm not seeing how Numbers makes my life easier in this regard.
    Any thoughts?

  • How do i know if a page is bookmarked

    When I bookmark a page, I see the star turns blue; however, when I return to that page, how can I tell if the page has been bookmarked before.
    Before the update, there would be a yellow star on the address bar. That is no longer available.
    Thank you for your assistance.

    The star on the Navigation Toolbar is highlighted blue when you are on a tab that is bookmarked.
    *https://support.mozilla.org/kb/use-bookmarks-to-save-and-organize-websites
    In current Firefox releases (29 and later), that have have the Australis user interface, the orange Firefox menu button has been replaced by the three-bar Firefox Menu button at the far right end of the Navigation Toolbar and this button is always visible, whether you have the menu bar visible or hidden<br>A consequence of this location is that you no longer can hide the Navigation Toolbar
    *There is a star like button to the right end of the search bar on the Navigation Toolbar to bookmark the current web page and a "Show your bookmarks" button next to it to open the Bookmarks in a drop down menu.<br>You can find "Show All Bookmarks" to open the Bookmarks Manager (Library) at the bottom of this drop-down list.
    *It is still possible to have the menu bar visible via the right-click context menu on the toolbars to have menus like the Bookmarks menu
    *<br>If you bookmark a page then "Bookmark This Page" in the Bookmarks menu changes to "Edit This Bookmark"
    See also:
    *https://support.mozilla.org/kb/how-to-make-new-firefox-look-like-old-firefox
    *https://support.mozilla.org/kb/common-questions-after-updating-to-new-firefox
    *https://support.mozilla.org/kb/learn-more-about-the-design-of-new-firefox

  • I have a question about extracting pages.  When I do the function, adobe saves the individual files as " file name space page number ", so the files look like this "filename 1.pdf", "filename 2.pdf", "filename 3.pdf".  Without too many gory details, I a

    I have a question about extracting pages.  When I do the function, adobe saves the individual files as "<file name><space><page number>", so the files look like this "filename 1.pdf", "filename 2.pdf", "filename 3.pdf".  Without too many gory details, I am using excel to concatenate some data to dynamically build a hyperlink to these extraced files.  It casues me problems, however, for the space to be the the file name.  Is there any way to change the default behavoir of this function to perhaps use a dash or underscore instead of a space?

    No, you can't change the default naming scheme. You can do it yourself if you extract the pages using a script instead of using the built-in command.

  • How do I extract pages from a PDF?

    I am trying to extract pages from a pdf document through Adobe XI and the command is not there through page thumbnails or through tools.  What can I do?  We have the current version which I verified through checking for updates.
    [Please choose only a short description for the thread title.]
    Message was edited by: Jim Simon

    "Adobe XI" does not exist.
    There is Acrobat XI (Standard or Pro).
    There is Adobe Reader XI.
    Acrobat XI Pro (and maybe Standard) can extract pages from a PDF.
    Adobe Reader XI cannot extract pages from a PDF.
    Once either application is open it is easy to determine which you have open.
    The "name" is in the top most "ribbon" of the application window.
    From what you've written it appears that you are using Adobe Reader XI.
    Be well...

  • Extracting Pages and Error Message

    My Adobe works great. I couldn't ask for a better product. However I have received a PDF file from a customer and I need to extract pages and insert them into another PDF. When I go to extract the pages I get an error message "Adobe Acrobat 9.0 has encountered a problem and needs to close. We are sorry for the inconvenience." and them the program shuts down. It is only with this one document and I can't find much information as to why this is happening.  Any ideas?
    Thank You!

    This sounds like an issue with the sort order display in Windows Explorer. If you use the File > Open dialog in Acrobat the files should display correctly.
    If you're previewing the PDFs in Windows Explorer try clicking the Name button underneath the toolbar to change the sort order from ascending to descending, then a single click again should display them correctly.

Maybe you are looking for