5 Replies Latest reply on Jun 1, 2016 12:00 AM by tobias.wantzen

    Small imposition script: Where to start?

    tobias.wantzen Level 1

      Hello all,


      I'm working in the publishing industry. When sending PDFs of books to proof readers, small books where placed two facing pages on a landscape A4 directly from within InDesign - so in result we have two »hard coded« InDesign pages on one PDF page. But it is possible to write single page PDFs and tell Acrobat to display with initial view »TwoPageRight«. On opening such a document, the user seems to view a facing pages document, but if he/she wants to print it, 2 facing pages on 1 A4 landscape, it doesn't work.

      Acrobat has some built-in possibilities to change the print layout for a single page document. But Acrobat always scales the pages and doesn't respect the first page being a right page.


      I need a small imposition script, that ...


      reads the page dimensions, and makes a new document with double width and single height of the original PDF.


      Then copies the pages as follows:

      1st page: duplicate and place as is (same dimensions as in original PDF) in front of the first page of new PDF.

      2nd page: copy content and place on left side of page 2 of new PDF

      3rd page: copy content and place on right side of page 2 of new PDF



      Optionally (checkbox): Draw a fine line around every original page while placing.


      Is something like this possible to script? And where is a good start for it?


      I don't exactly know where to start such a script. Can anybody give me a clue?




        • 1. Re: Small imposition script: Where to start?
          Bernd Alheit Adobe Community Professional & MVP

          You can create field buttons icon only)  and import the pages with the method buttonImportIcon.

          1 person found this helpful
          • 2. Re: Small imposition script: Where to start?
            Karl Heinz Kremer Adobe Community Professional

            As Bernd already suggested, the only way to do this in JavaScript is to use interactive buttons on which you then add a button icon that is a page from your PDF file that you want to impose.


            Take a look at the following two API documentation pages:

            Acrobat DC SDK Documentation - Doc.addField()

            Acrobat DC SDK Documentation - Field.buttonImportIcon()


            These two pages will allow you to add a button to a page and then import an image (representing a page) from a PDF file. To place and size the button, you will need to get the crop box of your page (which you very likely just created in your new document), via the Doc.getPageBox() method.


            To get this right, you will have to spend a considerable amount of time on this project. And, especially if you are just starting out with Acrobat JavaScript development, it may be much cheaper to just buy an imposition solution for Adobe Acrobat. A good example would be Quite Imposing, which is an Acrobat plug-in that has been around for a long time: Quite Imposing: home page

            1 person found this helpful
            • 3. Re: Small imposition script: Where to start?
              tobias.wantzen Level 1

              Thank you both for your suggestions and kind evaluation. I'll see, if I find enough resources to get a handle on this topic.



              • 4. Re: Small imposition script: Where to start?
                tobias.wantzen Level 1

                I tried to follow your clue and got it work. BUT: sadly not every page is imported at the right position (0,0) into the button field. Some pages have an y offset, some an x offset. I tried a lot, but couldn't find the bug. Here's my code up to now:


                // doc0
                var tDoc0 = this;
                var tDoc0Path = tDoc0.path
                tDoc1Path = tDoc0Path.replace(".pdf","_NEW.pdf");
                var tDoc1Pages = tDoc0.numPages;
                var tDoc1PagesLength = tDoc1Pages;
                var tDoc1PagesOdd = (tDoc1Pages - 1) % 2;
                var tSize = tDoc0.getPageBox("Crop",0);
                var tWidth = tSize[2]-tSize[0];
                var tHeight = tSize[1]-tSize[3];
                var tBuffer = 10;
                // doc1
                var tDoc1 = app.newDoc(tWidth*2+tBuffer,tHeight+tBuffer);
                tDoc1.setPageBoxes ({
                  cBox: "Crop",
                  nStart: 0,
                  nEnd: 0,
                  rBox: [0,tHeight,tWidth*2,0]
                // insert 1st page as single page
                tDoc1.insertPages ({
                  nPage: -1,
                  cPath: tDoc0Path,
                  nStart: 0,
                  nEnd: 0
                if ( tDoc1PagesOdd ) {  // last page will be inserted as single page
                  tDoc1PagesLength = tDoc1Pages - 1;
                for ( p0 = 1, pp1 = 1; p0 < tDoc1PagesLength; p0++, pp1+=0.5 ) {
                  p1 = parseInt(pp1);
                  var tLeftPage = p0 % 2;
                  if ( p1 > 1 && tLeftPage ) { 
                            nPage: pp1,
                            nWidth: tWidth*2+tBuffer,
                            nHeight: tHeight+tBuffer
                       tDoc1.setPageBoxes ({
                            cBox: "Crop",
                            nStart: p1,
                            nEnd: p1,
                            rBox: [0,tHeight,tWidth*2,0]
                  var tRect = [];
                  if ( tLeftPage ) {
                       tRect = [0,0,tWidth,tHeight];  // left page
                  } else {
                       tRect = [tWidth,0,tWidth*2,tHeight];  // right page
                  var tBtn = tDoc1.addField({
                       cName: "NextPage"+p0, 
                       cFieldType: "button",
                       nPageNum: p1,
                       oCoords: tRect }
                       cPath: tDoc0Path,
                       nPage: p0
                  tBtn.boderStyle = border.s;
                  tBtn.strokeColor = color.transparent;
                  tBtn.buttonPosition = position.iconOnly;
                  tBtn.display = display.visible;
                  tBtn.buttonFitBounds = true;
                  tBtn.buttonAlignX = 0;
                  tBtn.buttonAlignY = 0;
                  tBtn.buttonScaleHow = scaleHow.proportional;
                  tBtn.buttonScaleWhen = scaleWhen.never;
                // insert last single page
                if ( tDoc1PagesOdd ) {
                  tDoc1.insertPages ({
                  nPage: tDoc1.numPages - 1,
                  cPath: tDoc0Path,
                  nStart: tDoc1Pages - 1,
                  nEnd: tDoc1Pages -1


                I used this freely available PDF for testing:

                http://www.regensburger-orthopaedengemeinschaft.de/fileadmin/dateien/gemeinschaft/Orthojou rnal/16_01_OJ_26/OJ_26.pdf


                Any helpful idea is very welcome!




                • 5. Re: Small imposition script: Where to start?
                  tobias.wantzen Level 1

                  After reading Post Overlay PDF pages I changed the placement of PDFs from »buttonImportIcon« to »addWatermarkFromFile«.

                  All pages are now positioned correctly – no x/y deviations any more. But on screen and in print all fonts look a shade too thick compared with the original PDF. Can anybody tell me what Acrobat does with PDFs that are placed as watermarks? Are all texts converted to curves or something similar?