Rearrange PDF pages using the command-line












8















I want to rearrange the pages in a PDF file. But because I have to rearrange many pages, and the new arrangement has a specific pattern, I would like to do so with a script. Is there a simple program which allows to rearrange the pages in a PDF?



Alternatively I could also extract all pages and merge them together in the order I want. What progams are available to do this?










share|improve this question



























    8















    I want to rearrange the pages in a PDF file. But because I have to rearrange many pages, and the new arrangement has a specific pattern, I would like to do so with a script. Is there a simple program which allows to rearrange the pages in a PDF?



    Alternatively I could also extract all pages and merge them together in the order I want. What progams are available to do this?










    share|improve this question

























      8












      8








      8


      5






      I want to rearrange the pages in a PDF file. But because I have to rearrange many pages, and the new arrangement has a specific pattern, I would like to do so with a script. Is there a simple program which allows to rearrange the pages in a PDF?



      Alternatively I could also extract all pages and merge them together in the order I want. What progams are available to do this?










      share|improve this question














      I want to rearrange the pages in a PDF file. But because I have to rearrange many pages, and the new arrangement has a specific pattern, I would like to do so with a script. Is there a simple program which allows to rearrange the pages in a PDF?



      Alternatively I could also extract all pages and merge them together in the order I want. What progams are available to do this?







      command-line pdf






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Sep 6 '17 at 11:47









      red_trumpetred_trumpet

      6611826




      6611826






















          3 Answers
          3






          active

          oldest

          votes


















          9
















          pdftk is the one you're searching for. E.g. if you want to reverse the page order of i.pdf, do



          pdftk i.pdf cat end-1 output o.pdf


          Other examples showing pdftk's potential:



          pdftk i.pdf cat 4-1 6 8-end output o.pdf # use ranges
          pdftk i.pdf cat 1-6even output o.pdf # print only even pages in the range
          pdftk i.pdf cat 1-10 ~5-7 output o.pdf # exclude pages in the range
          pdftk i.pdf burst # extract to single-page pdf files


          Read man pdftk for more information.



          To install pdftk on 18.04 see: How can I install pdftk in Ubuntu 18.04 Bionic?





          If you after all search for a GUI solution have a look at pdftk's GUI pdfchain or pdfmod.






          share|improve this answer

































            2














            You can also try pdfjam pdfnup (based on LaTeX pdf-pages)



            Example:



            pdfjam i.pdf '{},2,1-5'         -o o.pdf
            pdfjam f1.pdf f2.pdf f3.pdf 1-3 -o o.pdf ## first 3 pages from f1,f2,f3




            • {} inserts an empty page

            • many options available (ex: scale, offset, trim, frame, nup) -- see pdfjam man






            share|improve this answer

































              0














              You can use qpdf which comes with ubuntu. This following command for example puts the pages in reverse order.



              qpdf --empty --pages infile.pdf z-1 -- outfile.pdf


              You can find more information and other examples here on pages 10 and 11.






              share|improve this answer























                Your Answer








                StackExchange.ready(function() {
                var channelOptions = {
                tags: "".split(" "),
                id: "89"
                };
                initTagRenderer("".split(" "), "".split(" "), channelOptions);

                StackExchange.using("externalEditor", function() {
                // Have to fire editor after snippets, if snippets enabled
                if (StackExchange.settings.snippets.snippetsEnabled) {
                StackExchange.using("snippets", function() {
                createEditor();
                });
                }
                else {
                createEditor();
                }
                });

                function createEditor() {
                StackExchange.prepareEditor({
                heartbeatType: 'answer',
                autoActivateHeartbeat: false,
                convertImagesToLinks: true,
                noModals: true,
                showLowRepImageUploadWarning: true,
                reputationToPostImages: 10,
                bindNavPrevention: true,
                postfix: "",
                imageUploader: {
                brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                allowUrls: true
                },
                onDemand: true,
                discardSelector: ".discard-answer"
                ,immediatelyShowMarkdownHelp:true
                });


                }
                });














                draft saved

                draft discarded


















                StackExchange.ready(
                function () {
                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f953271%2frearrange-pdf-pages-using-the-command-line%23new-answer', 'question_page');
                }
                );

                Post as a guest















                Required, but never shown

























                3 Answers
                3






                active

                oldest

                votes








                3 Answers
                3






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes









                9
















                pdftk is the one you're searching for. E.g. if you want to reverse the page order of i.pdf, do



                pdftk i.pdf cat end-1 output o.pdf


                Other examples showing pdftk's potential:



                pdftk i.pdf cat 4-1 6 8-end output o.pdf # use ranges
                pdftk i.pdf cat 1-6even output o.pdf # print only even pages in the range
                pdftk i.pdf cat 1-10 ~5-7 output o.pdf # exclude pages in the range
                pdftk i.pdf burst # extract to single-page pdf files


                Read man pdftk for more information.



                To install pdftk on 18.04 see: How can I install pdftk in Ubuntu 18.04 Bionic?





                If you after all search for a GUI solution have a look at pdftk's GUI pdfchain or pdfmod.






                share|improve this answer






























                  9
















                  pdftk is the one you're searching for. E.g. if you want to reverse the page order of i.pdf, do



                  pdftk i.pdf cat end-1 output o.pdf


                  Other examples showing pdftk's potential:



                  pdftk i.pdf cat 4-1 6 8-end output o.pdf # use ranges
                  pdftk i.pdf cat 1-6even output o.pdf # print only even pages in the range
                  pdftk i.pdf cat 1-10 ~5-7 output o.pdf # exclude pages in the range
                  pdftk i.pdf burst # extract to single-page pdf files


                  Read man pdftk for more information.



                  To install pdftk on 18.04 see: How can I install pdftk in Ubuntu 18.04 Bionic?





                  If you after all search for a GUI solution have a look at pdftk's GUI pdfchain or pdfmod.






                  share|improve this answer




























                    9












                    9








                    9









                    pdftk is the one you're searching for. E.g. if you want to reverse the page order of i.pdf, do



                    pdftk i.pdf cat end-1 output o.pdf


                    Other examples showing pdftk's potential:



                    pdftk i.pdf cat 4-1 6 8-end output o.pdf # use ranges
                    pdftk i.pdf cat 1-6even output o.pdf # print only even pages in the range
                    pdftk i.pdf cat 1-10 ~5-7 output o.pdf # exclude pages in the range
                    pdftk i.pdf burst # extract to single-page pdf files


                    Read man pdftk for more information.



                    To install pdftk on 18.04 see: How can I install pdftk in Ubuntu 18.04 Bionic?





                    If you after all search for a GUI solution have a look at pdftk's GUI pdfchain or pdfmod.






                    share|improve this answer

















                    pdftk is the one you're searching for. E.g. if you want to reverse the page order of i.pdf, do



                    pdftk i.pdf cat end-1 output o.pdf


                    Other examples showing pdftk's potential:



                    pdftk i.pdf cat 4-1 6 8-end output o.pdf # use ranges
                    pdftk i.pdf cat 1-6even output o.pdf # print only even pages in the range
                    pdftk i.pdf cat 1-10 ~5-7 output o.pdf # exclude pages in the range
                    pdftk i.pdf burst # extract to single-page pdf files


                    Read man pdftk for more information.



                    To install pdftk on 18.04 see: How can I install pdftk in Ubuntu 18.04 Bionic?





                    If you after all search for a GUI solution have a look at pdftk's GUI pdfchain or pdfmod.







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Aug 9 '18 at 11:09

























                    answered Sep 6 '17 at 11:49









                    dessertdessert

                    24.7k672105




                    24.7k672105

























                        2














                        You can also try pdfjam pdfnup (based on LaTeX pdf-pages)



                        Example:



                        pdfjam i.pdf '{},2,1-5'         -o o.pdf
                        pdfjam f1.pdf f2.pdf f3.pdf 1-3 -o o.pdf ## first 3 pages from f1,f2,f3




                        • {} inserts an empty page

                        • many options available (ex: scale, offset, trim, frame, nup) -- see pdfjam man






                        share|improve this answer






























                          2














                          You can also try pdfjam pdfnup (based on LaTeX pdf-pages)



                          Example:



                          pdfjam i.pdf '{},2,1-5'         -o o.pdf
                          pdfjam f1.pdf f2.pdf f3.pdf 1-3 -o o.pdf ## first 3 pages from f1,f2,f3




                          • {} inserts an empty page

                          • many options available (ex: scale, offset, trim, frame, nup) -- see pdfjam man






                          share|improve this answer




























                            2












                            2








                            2







                            You can also try pdfjam pdfnup (based on LaTeX pdf-pages)



                            Example:



                            pdfjam i.pdf '{},2,1-5'         -o o.pdf
                            pdfjam f1.pdf f2.pdf f3.pdf 1-3 -o o.pdf ## first 3 pages from f1,f2,f3




                            • {} inserts an empty page

                            • many options available (ex: scale, offset, trim, frame, nup) -- see pdfjam man






                            share|improve this answer















                            You can also try pdfjam pdfnup (based on LaTeX pdf-pages)



                            Example:



                            pdfjam i.pdf '{},2,1-5'         -o o.pdf
                            pdfjam f1.pdf f2.pdf f3.pdf 1-3 -o o.pdf ## first 3 pages from f1,f2,f3




                            • {} inserts an empty page

                            • many options available (ex: scale, offset, trim, frame, nup) -- see pdfjam man







                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited Feb 19 '18 at 20:39









                            dessert

                            24.7k672105




                            24.7k672105










                            answered Sep 6 '17 at 17:27









                            JJoaoJJoao

                            1,40069




                            1,40069























                                0














                                You can use qpdf which comes with ubuntu. This following command for example puts the pages in reverse order.



                                qpdf --empty --pages infile.pdf z-1 -- outfile.pdf


                                You can find more information and other examples here on pages 10 and 11.






                                share|improve this answer




























                                  0














                                  You can use qpdf which comes with ubuntu. This following command for example puts the pages in reverse order.



                                  qpdf --empty --pages infile.pdf z-1 -- outfile.pdf


                                  You can find more information and other examples here on pages 10 and 11.






                                  share|improve this answer


























                                    0












                                    0








                                    0







                                    You can use qpdf which comes with ubuntu. This following command for example puts the pages in reverse order.



                                    qpdf --empty --pages infile.pdf z-1 -- outfile.pdf


                                    You can find more information and other examples here on pages 10 and 11.






                                    share|improve this answer













                                    You can use qpdf which comes with ubuntu. This following command for example puts the pages in reverse order.



                                    qpdf --empty --pages infile.pdf z-1 -- outfile.pdf


                                    You can find more information and other examples here on pages 10 and 11.







                                    share|improve this answer












                                    share|improve this answer



                                    share|improve this answer










                                    answered 37 mins ago









                                    SaTaSaTa

                                    6017




                                    6017






























                                        draft saved

                                        draft discarded




















































                                        Thanks for contributing an answer to Ask Ubuntu!


                                        • Please be sure to answer the question. Provide details and share your research!

                                        But avoid



                                        • Asking for help, clarification, or responding to other answers.

                                        • Making statements based on opinion; back them up with references or personal experience.


                                        To learn more, see our tips on writing great answers.




                                        draft saved


                                        draft discarded














                                        StackExchange.ready(
                                        function () {
                                        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f953271%2frearrange-pdf-pages-using-the-command-line%23new-answer', 'question_page');
                                        }
                                        );

                                        Post as a guest















                                        Required, but never shown





















































                                        Required, but never shown














                                        Required, but never shown












                                        Required, but never shown







                                        Required, but never shown

































                                        Required, but never shown














                                        Required, but never shown












                                        Required, but never shown







                                        Required, but never shown







                                        Popular posts from this blog

                                        GameSpot

                                        日野市

                                        Tu-95轟炸機