4 Replies Latest reply on Jul 2, 2010 5:06 AM by mjelsner96

    Export Specific Documents from a Book - VB

    mjelsner96

      I have a book file(many of them) that I am trying to export specific documents from them.  I see that on the book.export object I can pass it which documents, but I am not sure how to tell it which documents.  Here is what I have so far.  I plan to loop through the documents in the book and pick out the ones that I need.  Can anyone tell me how to do this?

       

      Thanks

       

      For

       

       

      i = myBook.BookContents.Count To 1 Step -1

      myBook.AutomaticPagination = False

      strDocName = myBook.BookContents.Item(i).FullName

       

       

      If strDocName.ToLower.Contains("_title") Or strDocName.ToLower.Contains("_hb") Then

       

      ???-add documents to array maybe?

       

      End If

       

       

      Next

       

       

       

      myBook.Export(strExportPath, , , ????)

        • 1. Re: Export Specific Documents from a Book - VB
          [Jongware] Most Valuable Participant

          That seems to be the right direction, yes. You are referring to the exportFile parameter "whichDocuments":

           

          Used to specify a list of book content references, from the current book, where the list may contain duplicate entries and if the list is not specified then the entire book contents shall be exported (Optional)

           

          and its type is a simple array of BookContents. (Coming so far, I realize you are working with VB, and my experience is limited to Javascript. But the general idea should be the same.)

           

          In JS, you create the array with

           

          var docArray = new Array();

           

          then "push" the required elements into it (... I don't think there is a VB equivalent!):

           

          if (strDocName.toLowerCase.indexOf("_title") > -1 || strDocName.toLowerCase.indexOf("_hb") > -1)

             docArray.push  (myBook.bookContents.item(i));

           

          and use this array in the export function:

           

          myBook.exportFile (File("myOutput.pdf"), false, somePDfPreset, docArray);

          • 2. Re: Export Specific Documents from a Book - VB
            mjelsner96 Level 1

            k I figured out how to do this.  Is there a way to preserve the page numbering.  The documents I will be exporting might be page 1-3 and pages 80-120.  But pages 1-3 have a TOC that will be wrong when I export as it renumbers.

             

            Thanks

             

            For

             

             

            iCount As Integer = 1 To myBook.BookContents.Count

            myBook.AutomaticPagination =

            False

            strDocName = myBook.BookContents.Item(iCount).FullName

             

            If strDocName.ToLower.Contains("_title") Or strDocName.ToLower.Contains("_hb") Then

            arExportFiles(iFoundCount) = myBook.BookContents.Item(iCount)

            iFoundCount = +1

             

            End If

             

            Next

            • 3. Re: Export Specific Documents from a Book - VB
              [Jongware] Most Valuable Participant

              Sorry, what page numbers are you referring to? I don't think it works in any other way than it does in the UI.

              • 4. Re: Export Specific Documents from a Book - VB
                mjelsner96 Level 1

                I was referring to the page numbers of the documents, but like you said it doesn't do anything the UI doesn't do.  I was just wondering if there was a different way to do it in the UI that I was thinking of.  Thanks for the reply.