Merge two pdf files side by side in command line











up vote
5
down vote

favorite
1












I have got two pdf files with same number of pages and want compare each page with the corresponding page in the other file. For this I would like to merge say page 1 of File1.pdf with page 1 of File2.pdf so it gets one page in the new document. Then page 2 of File1.pdf with page 2 of File2.pdf and make it page 2 of the new file.



In this question I learned already that I can put two pages on one page with the --nup option of the pdfjam command:



pdfjam File1.pdf File2.pdf --nup 2x1 --landscape --outfile File1+2.pdf


The same can be achieved with the ImageMagick package:



montage *.pdf merged.pdf


But this puts together page 1 and page 2 of the first file and does the same later on with the second file - not as intended.



What I did is to split the two documents. The first file got even numbers in the file name, the second odd numbers (actually I created the files anew with appropriate file names). Then I merged all files again with



pdftk *.pdf cat output merged.pdf


and finally put two pages on one with



pdfjam --nup 2x1 --landscape --outfile merged2up.pdf merged.pdf


I could write a script with a loop doing this, but I was wondering whether there is an easy one-liner to achieve this? Maybe I didn't find the right pdfjam, pdftk or ImageMagick command?










share|improve this question
























  • Still two commands, but my pdftk has a "shuffle" option, which looks like it would allow you to merge the two documents with alternating pages without needing to first split them to individual pages. At that point, many PDF viewers have an option to show two pages at once side by side, so you might not even need the "N up" operation at that point.
    – arcticmac
    Apr 25 '16 at 18:46















up vote
5
down vote

favorite
1












I have got two pdf files with same number of pages and want compare each page with the corresponding page in the other file. For this I would like to merge say page 1 of File1.pdf with page 1 of File2.pdf so it gets one page in the new document. Then page 2 of File1.pdf with page 2 of File2.pdf and make it page 2 of the new file.



In this question I learned already that I can put two pages on one page with the --nup option of the pdfjam command:



pdfjam File1.pdf File2.pdf --nup 2x1 --landscape --outfile File1+2.pdf


The same can be achieved with the ImageMagick package:



montage *.pdf merged.pdf


But this puts together page 1 and page 2 of the first file and does the same later on with the second file - not as intended.



What I did is to split the two documents. The first file got even numbers in the file name, the second odd numbers (actually I created the files anew with appropriate file names). Then I merged all files again with



pdftk *.pdf cat output merged.pdf


and finally put two pages on one with



pdfjam --nup 2x1 --landscape --outfile merged2up.pdf merged.pdf


I could write a script with a loop doing this, but I was wondering whether there is an easy one-liner to achieve this? Maybe I didn't find the right pdfjam, pdftk or ImageMagick command?










share|improve this question
























  • Still two commands, but my pdftk has a "shuffle" option, which looks like it would allow you to merge the two documents with alternating pages without needing to first split them to individual pages. At that point, many PDF viewers have an option to show two pages at once side by side, so you might not even need the "N up" operation at that point.
    – arcticmac
    Apr 25 '16 at 18:46













up vote
5
down vote

favorite
1









up vote
5
down vote

favorite
1






1





I have got two pdf files with same number of pages and want compare each page with the corresponding page in the other file. For this I would like to merge say page 1 of File1.pdf with page 1 of File2.pdf so it gets one page in the new document. Then page 2 of File1.pdf with page 2 of File2.pdf and make it page 2 of the new file.



In this question I learned already that I can put two pages on one page with the --nup option of the pdfjam command:



pdfjam File1.pdf File2.pdf --nup 2x1 --landscape --outfile File1+2.pdf


The same can be achieved with the ImageMagick package:



montage *.pdf merged.pdf


But this puts together page 1 and page 2 of the first file and does the same later on with the second file - not as intended.



What I did is to split the two documents. The first file got even numbers in the file name, the second odd numbers (actually I created the files anew with appropriate file names). Then I merged all files again with



pdftk *.pdf cat output merged.pdf


and finally put two pages on one with



pdfjam --nup 2x1 --landscape --outfile merged2up.pdf merged.pdf


I could write a script with a loop doing this, but I was wondering whether there is an easy one-liner to achieve this? Maybe I didn't find the right pdfjam, pdftk or ImageMagick command?










share|improve this question















I have got two pdf files with same number of pages and want compare each page with the corresponding page in the other file. For this I would like to merge say page 1 of File1.pdf with page 1 of File2.pdf so it gets one page in the new document. Then page 2 of File1.pdf with page 2 of File2.pdf and make it page 2 of the new file.



In this question I learned already that I can put two pages on one page with the --nup option of the pdfjam command:



pdfjam File1.pdf File2.pdf --nup 2x1 --landscape --outfile File1+2.pdf


The same can be achieved with the ImageMagick package:



montage *.pdf merged.pdf


But this puts together page 1 and page 2 of the first file and does the same later on with the second file - not as intended.



What I did is to split the two documents. The first file got even numbers in the file name, the second odd numbers (actually I created the files anew with appropriate file names). Then I merged all files again with



pdftk *.pdf cat output merged.pdf


and finally put two pages on one with



pdfjam --nup 2x1 --landscape --outfile merged2up.pdf merged.pdf


I could write a script with a loop doing this, but I was wondering whether there is an easy one-liner to achieve this? Maybe I didn't find the right pdfjam, pdftk or ImageMagick command?







command-line pdf imagemagick pdftk






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 20 '17 at 10:04









Community

1




1










asked May 20 '15 at 12:24









nnn

13616




13616












  • Still two commands, but my pdftk has a "shuffle" option, which looks like it would allow you to merge the two documents with alternating pages without needing to first split them to individual pages. At that point, many PDF viewers have an option to show two pages at once side by side, so you might not even need the "N up" operation at that point.
    – arcticmac
    Apr 25 '16 at 18:46


















  • Still two commands, but my pdftk has a "shuffle" option, which looks like it would allow you to merge the two documents with alternating pages without needing to first split them to individual pages. At that point, many PDF viewers have an option to show two pages at once side by side, so you might not even need the "N up" operation at that point.
    – arcticmac
    Apr 25 '16 at 18:46
















Still two commands, but my pdftk has a "shuffle" option, which looks like it would allow you to merge the two documents with alternating pages without needing to first split them to individual pages. At that point, many PDF viewers have an option to show two pages at once side by side, so you might not even need the "N up" operation at that point.
– arcticmac
Apr 25 '16 at 18:46




Still two commands, but my pdftk has a "shuffle" option, which looks like it would allow you to merge the two documents with alternating pages without needing to first split them to individual pages. At that point, many PDF viewers have an option to show two pages at once side by side, so you might not even need the "N up" operation at that point.
– arcticmac
Apr 25 '16 at 18:46










2 Answers
2






active

oldest

votes

















up vote
3
down vote













You can split File1.pdf and File2.pdf into pages and then combine those tmp files into File1+2.pdf like so:



# Split files, note the naming scheme
pdfseparate File1.pdf temp-%04d-file1.pdf
pdfseparate File2.pdf temp-%04d-file2.pdf

# Combine the final pdf
pdfjam temp-*-*.pdf --nup 2x1 --landscape --outfile File1+2.pdf

# Clean up
rm -f temp-*-*.pdf





share|improve this answer





















  • Thanks for this solution. However, the merged file is not really size optimized. In my case it's nearly 100 times bigger than the source files. Does someone know how to reduce the size of the merged file?
    – Stefan Endrullis
    Jun 12 at 13:01


















up vote
-1
down vote













A, err, little late, but may be helpful to some one else.



The original approach of the OP, to display pages side-by-side, can be achieved by the other answer given.



However, the approach may be arduous if the aim is to find some small textual difference. To that goal, use a pdfdiff, of which there are a few from different authors, commercial, open-sourced, command-line and GUI alike.



https://duckduckgo.com/?q=pdfdiff&t=ffab&ia=software



Note that this approach is not as effective for images as "identical" images can be encoded differently.






share|improve this answer

















  • 1




    Can you explain how to use this software? Giving link only is only a half-way solution. And you don't even link to where the software is located at. Please consider to expand your answer with the essential info.
    – Vylix
    Nov 17 '17 at 13:48











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
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',
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%2fsuperuser.com%2fquestions%2f917190%2fmerge-two-pdf-files-side-by-side-in-command-line%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
3
down vote













You can split File1.pdf and File2.pdf into pages and then combine those tmp files into File1+2.pdf like so:



# Split files, note the naming scheme
pdfseparate File1.pdf temp-%04d-file1.pdf
pdfseparate File2.pdf temp-%04d-file2.pdf

# Combine the final pdf
pdfjam temp-*-*.pdf --nup 2x1 --landscape --outfile File1+2.pdf

# Clean up
rm -f temp-*-*.pdf





share|improve this answer





















  • Thanks for this solution. However, the merged file is not really size optimized. In my case it's nearly 100 times bigger than the source files. Does someone know how to reduce the size of the merged file?
    – Stefan Endrullis
    Jun 12 at 13:01















up vote
3
down vote













You can split File1.pdf and File2.pdf into pages and then combine those tmp files into File1+2.pdf like so:



# Split files, note the naming scheme
pdfseparate File1.pdf temp-%04d-file1.pdf
pdfseparate File2.pdf temp-%04d-file2.pdf

# Combine the final pdf
pdfjam temp-*-*.pdf --nup 2x1 --landscape --outfile File1+2.pdf

# Clean up
rm -f temp-*-*.pdf





share|improve this answer





















  • Thanks for this solution. However, the merged file is not really size optimized. In my case it's nearly 100 times bigger than the source files. Does someone know how to reduce the size of the merged file?
    – Stefan Endrullis
    Jun 12 at 13:01













up vote
3
down vote










up vote
3
down vote









You can split File1.pdf and File2.pdf into pages and then combine those tmp files into File1+2.pdf like so:



# Split files, note the naming scheme
pdfseparate File1.pdf temp-%04d-file1.pdf
pdfseparate File2.pdf temp-%04d-file2.pdf

# Combine the final pdf
pdfjam temp-*-*.pdf --nup 2x1 --landscape --outfile File1+2.pdf

# Clean up
rm -f temp-*-*.pdf





share|improve this answer












You can split File1.pdf and File2.pdf into pages and then combine those tmp files into File1+2.pdf like so:



# Split files, note the naming scheme
pdfseparate File1.pdf temp-%04d-file1.pdf
pdfseparate File2.pdf temp-%04d-file2.pdf

# Combine the final pdf
pdfjam temp-*-*.pdf --nup 2x1 --landscape --outfile File1+2.pdf

# Clean up
rm -f temp-*-*.pdf






share|improve this answer












share|improve this answer



share|improve this answer










answered Jun 9 '17 at 8:53









Sergei

1313




1313












  • Thanks for this solution. However, the merged file is not really size optimized. In my case it's nearly 100 times bigger than the source files. Does someone know how to reduce the size of the merged file?
    – Stefan Endrullis
    Jun 12 at 13:01


















  • Thanks for this solution. However, the merged file is not really size optimized. In my case it's nearly 100 times bigger than the source files. Does someone know how to reduce the size of the merged file?
    – Stefan Endrullis
    Jun 12 at 13:01
















Thanks for this solution. However, the merged file is not really size optimized. In my case it's nearly 100 times bigger than the source files. Does someone know how to reduce the size of the merged file?
– Stefan Endrullis
Jun 12 at 13:01




Thanks for this solution. However, the merged file is not really size optimized. In my case it's nearly 100 times bigger than the source files. Does someone know how to reduce the size of the merged file?
– Stefan Endrullis
Jun 12 at 13:01












up vote
-1
down vote













A, err, little late, but may be helpful to some one else.



The original approach of the OP, to display pages side-by-side, can be achieved by the other answer given.



However, the approach may be arduous if the aim is to find some small textual difference. To that goal, use a pdfdiff, of which there are a few from different authors, commercial, open-sourced, command-line and GUI alike.



https://duckduckgo.com/?q=pdfdiff&t=ffab&ia=software



Note that this approach is not as effective for images as "identical" images can be encoded differently.






share|improve this answer

















  • 1




    Can you explain how to use this software? Giving link only is only a half-way solution. And you don't even link to where the software is located at. Please consider to expand your answer with the essential info.
    – Vylix
    Nov 17 '17 at 13:48















up vote
-1
down vote













A, err, little late, but may be helpful to some one else.



The original approach of the OP, to display pages side-by-side, can be achieved by the other answer given.



However, the approach may be arduous if the aim is to find some small textual difference. To that goal, use a pdfdiff, of which there are a few from different authors, commercial, open-sourced, command-line and GUI alike.



https://duckduckgo.com/?q=pdfdiff&t=ffab&ia=software



Note that this approach is not as effective for images as "identical" images can be encoded differently.






share|improve this answer

















  • 1




    Can you explain how to use this software? Giving link only is only a half-way solution. And you don't even link to where the software is located at. Please consider to expand your answer with the essential info.
    – Vylix
    Nov 17 '17 at 13:48













up vote
-1
down vote










up vote
-1
down vote









A, err, little late, but may be helpful to some one else.



The original approach of the OP, to display pages side-by-side, can be achieved by the other answer given.



However, the approach may be arduous if the aim is to find some small textual difference. To that goal, use a pdfdiff, of which there are a few from different authors, commercial, open-sourced, command-line and GUI alike.



https://duckduckgo.com/?q=pdfdiff&t=ffab&ia=software



Note that this approach is not as effective for images as "identical" images can be encoded differently.






share|improve this answer












A, err, little late, but may be helpful to some one else.



The original approach of the OP, to display pages side-by-side, can be achieved by the other answer given.



However, the approach may be arduous if the aim is to find some small textual difference. To that goal, use a pdfdiff, of which there are a few from different authors, commercial, open-sourced, command-line and GUI alike.



https://duckduckgo.com/?q=pdfdiff&t=ffab&ia=software



Note that this approach is not as effective for images as "identical" images can be encoded differently.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 17 '17 at 11:30









jackpots

1




1








  • 1




    Can you explain how to use this software? Giving link only is only a half-way solution. And you don't even link to where the software is located at. Please consider to expand your answer with the essential info.
    – Vylix
    Nov 17 '17 at 13:48














  • 1




    Can you explain how to use this software? Giving link only is only a half-way solution. And you don't even link to where the software is located at. Please consider to expand your answer with the essential info.
    – Vylix
    Nov 17 '17 at 13:48








1




1




Can you explain how to use this software? Giving link only is only a half-way solution. And you don't even link to where the software is located at. Please consider to expand your answer with the essential info.
– Vylix
Nov 17 '17 at 13:48




Can you explain how to use this software? Giving link only is only a half-way solution. And you don't even link to where the software is located at. Please consider to expand your answer with the essential info.
– Vylix
Nov 17 '17 at 13:48


















draft saved

draft discarded




















































Thanks for contributing an answer to Super User!


  • 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.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • 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%2fsuperuser.com%2fquestions%2f917190%2fmerge-two-pdf-files-side-by-side-in-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

Plaza Victoria

Puebla de Zaragoza

Musa