16 Replies Latest reply on May 30, 2016 3:09 AM by Bachu

    Overlay PDF pages

    Bachu Level 1

      Hello, I have 200+ pages PDF file and i want to overlay all pages on a single page. Is this possible through Acrobat JavaScript? I have tried overlaying pages by converting it to images using VBA on Microsoft PPT but for some reason its getting stuck. I am not a JavaScript programmer, so, Any help would be greatly appreciated. I am currently using Adobe Acrobat Professional 9 pro. Thanks in Advance.

        • 1. Re: Overlay PDF pages
          maxwyss Level 4

          It depends on what exactly you want to accomplish, but there are various approaches.

           

          Probably the most common one would be using OCGs (Optional Content Groups, sometimes also called "layers"). You would import the document page by page, and turn them into a (named) OCG. Then you can show/hide them, either script-controlled or manually.

           

          A similar approach would be creating button fields of the size of a page, import the page as the icon, and then show/hide those fields

           

          Finally, you may also look at the Template functionality (which has some limitations with Reader).

           

          In any case, don't fiddle around with pseudo-images, if you can use PDF (which you can do in the methods mentioned above).

           

          Hope this can help.

          1 person found this helpful
          • 2. Re: Overlay PDF pages
            Bachu Level 1

            Thank you so much Max,

             

            I am actually trying to find out if there is any text outside the set margin in the PDF. This PDF was generated using some third party tool. Dose OCGs or template functionality helps me find out text outside margin?

            • 3. Re: Overlay PDF pages
              Bachu Level 1

              I would like to share a PDF that i am currently working on. PDF has a green box around the content on every page and on some page text is running outside the green box. I am not sure how to attach PDF in the forum. Please let me know if we can attach PDF in forum.

              • 4. Re: Overlay PDF pages
                try67 MVP & Adobe Community Professional

                You can't upload it here directly. You can share a link to it via a file-sharing site like Dropbox, Google Drive, Adobe Cloud, etc.

                • 5. Re: Overlay PDF pages
                  maxwyss Level 4

                  You're welcome Bachu.

                   

                  Acrobat JavaScript's capability is only very limited to find contents, and it would have to be within the cropbox anyway. So, if the page is cropped, contents outside of the cropbox is ignored. However, if you want to get rid of it before importing, you could set the mediabox of the page to the cropbox. That should get rid of such contents.

                  • 6. Re: Overlay PDF pages
                    Bachu Level 1

                    Thank you.

                    • 7. Re: Overlay PDF pages
                      Bachu Level 1

                      3 pages.pdf - Google Drive Here is the link to the PDF. Please let me know the best approach to find text outside the green box. Also, as Acrobat JavaScript has limited capability to deal with the issue, suggest me any other coding language which helps me solve this issue.

                       

                      Thought of overlaying PDF pages one on the other of a complete PDF when i saw below youtube video about "PIXEDIT" stack image functionality. Please have a look at it @ 24 Page Stacking Images in PixEdit Document Scanning and Editing Software. - YouTube

                      where they even fixed the issue. However, i just want to identify which PDF page has this issue. Fixing the issue would be done in XML document.

                      • 8. Re: Overlay PDF pages
                        Bachu Level 1

                        Second page of attached 3 pages PDF has text outside the green box. Missed to add this point in the above comment.

                        • 9. Re: Overlay PDF pages
                          Bachu Level 1

                          Hello try67, Any idea on how to overlay PDF pages one on the other? I was looking for a solution since so many days and finally decided to overlay PDF pages but don't know how to do it using Acrobat JavaScript.

                          • 10. Re: Overlay PDF pages
                            try67 MVP & Adobe Community Professional

                            You can overlay one PDF on top of another by using the addWatermarkFromFile method of the Document object.

                            1 person found this helpful
                            • 11. Re: Overlay PDF pages
                              Bachu Level 1

                              Thanks try67, but that is not what i am looking for.

                              • 12. Re: Overlay PDF pages
                                try67 MVP & Adobe Community Professional

                                Then you'll need to elaborate a bit about what you want to achieve...

                                • 13. Re: Overlay PDF pages
                                  Bachu Level 1

                                  I want to find the instances of "text running outside the green box". Here is the sample file 3 pages.pdf - Google Drive which has one instance on the second page. What i think is, when we overlay 3 pages on  a single page we will get to see if there is any text running outside the green box. Suggest me the ways to solve this issue.

                                  • 14. Re: Overlay PDF pages
                                    Test Screen Name Most Valuable Participant

                                    This seems a very convoluted path. Why not get the location of each word in the PDF and see if any words sit outside the box?

                                    • 15. Re: Overlay PDF pages
                                      Karl Heinz Kremer Adobe Community Professional

                                      TSN's approach can actually be done in JavaScript - as long as you know the location and size of the green box. The trick is to figure out of any part of a word is outside of that green box.

                                       

                                      Take a look at the "word finder": Acrobat DC SDK Documentation  - Doc.getPageNthWordQuads() The documentation for Doc.getPageNthWord() has a reference to an example ("Example 2") that demonstrates how to iterate over all words.

                                       

                                      What you want to do with overlaying page content is not easily possible in Acrobat. Two potential solutions were already mentioned (layers, which would require you to split the document into individual pages and then import them as payers), and watermarks (which would require you to apply every page in your document as a watermark). This approach does have limitations however: When a page has a white background, it will obscure everything else that was placed on the "page layer stack" so far, and you will not be able to see what was put on that stack before.

                                       

                                      If you really want to use this overlay approach. I actually have a tool that I wrote for myself while analyzing customer files a while ago that takes every page of a document and creates such a composite page. It's a Java program that would require you to have Java installed (this is different from JavaScript). You can download it from here: MergePages.jar

                                       

                                      There is no warranty associated with that download, it works well for the kind of file it was designed for, but it may not work for you. If you choose to download the file, you are doing this at your own risk.

                                       

                                      If you do download it, you would run it from the command line as follows:

                                       

                                      java -jar MergePages.jar input.pdf output.pdf
                                      
                                      • 16. Re: Overlay PDF pages
                                        Bachu Level 1

                                        Hi Karl,

                                         

                                        Thank you so much!!. This is exactly what am looking for. Its working fine and i don't think any changes required.

                                         

                                        I will try to convert this JAR file to EXE file which will run without JDK on windows system.

                                         

                                        Once again Thank you so much!