8 Replies Latest reply on Apr 17, 2013 6:17 AM by DatGuardian

    Export 2 pages in a new file (e.g. 5 and 9)

    DatGuardian

      Hi,

       

      i have to export 2 Pages in a new file via button.

       

      There is an option for export a page, but this option only lets you export pages which directly following (1 -3 or 6-9 but not 5 and 9)

       

      One of the pages could be anywhere in this document, so i want to export it with this code

      trustedexPa = app.trustedFunction( function ()

      {

                // Additional code may appear above

                app.beginPriv();    // Explicitly raise privilege

                this.extractPages({nStart: this.pageNum, nEnd: this.pageNum});

                app.endPriv();

                // Additional code may appear below.

      });

       

      (the button always is on this page)

       

      the Second page is ALWAYS page nr. 2

       

      So now i have to create a button which exports the actual page + page 2 in a new file with a single click.

       

      Do you have any ideas?

       

      Sincerely

      Timo

        • 1. Re: Export 2 pages in a new file (e.g. 5 and 9)
          try67 MVP & Adobe Community Professional

          This can't be done with a single command. You will need to extract both pages to temporary files, and then create a new file and insert them into it. Extracting, creating new files, inserting pages and saving such a file would all require trusted functions like the one you have created, but you would need to make them more generic than that. In other words, you should pass all the necessary information as parameters, not hard-code it into your function.

          1 person found this helpful
          • 2. Re: Export 2 pages in a new file (e.g. 5 and 9)
            DatGuardian Level 1

            Mhhh ok,

             

            my solution is now like that:

             

            i have 2 buttons and one textbox

             

            The first button saves the acual path in the textbox on the actual site which have to be exported.

            The second button must be clicked in the new created file which inserts the page out of the other file using the path saved in the textbox

             

             

             

            http://i.imgur.com/Yh9efzu.png

             

            Button 1

            this.getField("pfad").value = this.path;

            trustedexPa();

             

            Button 2 (pressed in the new document)

            trustedInPa(-1, this.getField("pfad").value, 0, 0);

            • 3. Re: Export 2 pages in a new file (e.g. 5 and 9)
              try67 MVP & Adobe Community Professional

              Sorry, I'm not really following what you're trying to do there...

              • 4. Re: Export 2 pages in a new file (e.g. 5 and 9)
                DatGuardian Level 1

                I have a document with 20 pages.

                 

                A new document has to be created out of page 2 and a page which isn't always at the same position in the document.

                 

                So i made a button on the variating page which writes the file path in a textbox and extract this page in a new file.

                 

                Button 1

                this.getField("pfad").value = this.path;

                trustedexPa(this);

                 

                Here is the trustedexPa:

                 

                trustedexPa = app.trustedFunction( function (doc)

                {

                          // Additional code may appear above

                          app.beginPriv();    // Explicitly raise privilege

                  doc.extractPages({nStart: this.pageNum, nEnd: this.pageNum});

                          app.endPriv();

                          // Additional code may appear below.

                });

                 

                 

                When the new file is created the user has to click on the second button (in the new created file) to insert page 2 from the original.

                 

                Button 2 (pressed in the new document)

                trustedInPa(-1, this.getField("pfad").value, 0, 0);

                 

                Here the trustedinPa:

                 

                trustedInPa = app.trustedFunction( function (startseite, pfad, eStart, eEnde)

                {

                          app.beginPriv();    // Explicitly raise privilege

                this.insertPages({nPage: startseite,cPath: pfad,nStart: eStart,nEnd: eEnde});

                          app.endPriv();

                });

                 

                This way it works.

                 

                 

                • 5. Re: Export 2 pages in a new file (e.g. 5 and 9)
                  try67 MVP & Adobe Community Professional

                  Why use buttons in the document itself? Use a folder-level script to add a

                  menu item in Acrobat and do everything there.

                  • 6. Re: Export 2 pages in a new file (e.g. 5 and 9)
                    DatGuardian Level 1

                    Because two reasons:

                     

                    I think i can't use 'trustedexPa(this);' in the menu

                     

                    Reason 2: The users wouldn't accept this. So my boss does....

                    • 7. Re: Export 2 pages in a new file (e.g. 5 and 9)
                      try67 MVP & Adobe Community Professional

                      1. Yes, it would work.

                      2. I don't really see the difference. If anything, it makes much more

                      sense... But nevermind.

                      So you can use what you're using now, you just need to get the page number

                      of the other page somehow (prompt the user to enter it, for example).

                      • 8. Re: Export 2 pages in a new file (e.g. 5 and 9)
                        DatGuardian Level 1

                        try67 wrote:

                         

                        So you can use what you're using now, you just need to get the page number

                        of the other page somehow (prompt the user to enter it, for example).

                        That is the point.

                        I do not trust the users just as my boss.

                        All has to be automated as much as it can!

                         

                        This is a source of a possible error, which 'this' deletes

                         

                        The button 1 and 2 will now disable themselfes due to prevent from clicking it twice

                         

                        But thank you for your input!