Save each pdf file of a directory as another pdf (operation similar to print a pdf as a pdf)












1














Consider the following procedure:



1) Open a pdf file using the (ubuntu) document viewer.



2) Goto File



3) Goto print



4) Choose print as file and check the mark "pdf"



Yes, I am printing a pdf as pdf file. I have to do this for a large collection of files. I would like to do this running a script at the terminal.



Maybe you think that this procedure does not make any sense at all, but it actually was the only safe way I found to deal with the issue considered here. This stackoverflow question shows a problem with pdf files the EOF marker is not found. When I do the procedure described above, I am able to solve this problem [This is not the solution presented in stackoverflow site, which does not work here.]



I would like to this automatically with all files that present this issue.



I know that I should build one script (.sh) to this, but I do not know how to proceed.



An example of the pdf file (1) with problems is here



The corrected pdf file (2) is here



The only difference between them is that I opened the first using the "ubuntu document viewer", I went to "File", "Print", "Print to File", "Output=pdf".



I want to make this automatically.



EDIT:



I do NOT want to merge the files.










share|improve this question




















  • 1




    Do you want to print them (on paper, using a printer) or "save them in another directory from terminal"?
    – terdon
    Dec 12 at 12:29










  • Save in another directory as pdf.
    – DanielTheRocketMan
    Dec 12 at 12:36










  • However, I do not want to copy them.
    – DanielTheRocketMan
    Dec 12 at 12:38






  • 1




    So you want to copy them? Are you just looking for a script that will run cp orig.pdf copy.pdf for each file? You've linked to an SO question with a lot of text and a lot of python, why is that relevant? Please edit and explain what you need.
    – terdon
    Dec 12 at 12:38








  • 1




    "The pdfminer error mentioned above": what is this error? How can we reproduce it so we can test our answers? If it is explained in the linked Stack Overflow question, then please reproduce the relevant information here.
    – terdon
    Dec 12 at 15:11
















1














Consider the following procedure:



1) Open a pdf file using the (ubuntu) document viewer.



2) Goto File



3) Goto print



4) Choose print as file and check the mark "pdf"



Yes, I am printing a pdf as pdf file. I have to do this for a large collection of files. I would like to do this running a script at the terminal.



Maybe you think that this procedure does not make any sense at all, but it actually was the only safe way I found to deal with the issue considered here. This stackoverflow question shows a problem with pdf files the EOF marker is not found. When I do the procedure described above, I am able to solve this problem [This is not the solution presented in stackoverflow site, which does not work here.]



I would like to this automatically with all files that present this issue.



I know that I should build one script (.sh) to this, but I do not know how to proceed.



An example of the pdf file (1) with problems is here



The corrected pdf file (2) is here



The only difference between them is that I opened the first using the "ubuntu document viewer", I went to "File", "Print", "Print to File", "Output=pdf".



I want to make this automatically.



EDIT:



I do NOT want to merge the files.










share|improve this question




















  • 1




    Do you want to print them (on paper, using a printer) or "save them in another directory from terminal"?
    – terdon
    Dec 12 at 12:29










  • Save in another directory as pdf.
    – DanielTheRocketMan
    Dec 12 at 12:36










  • However, I do not want to copy them.
    – DanielTheRocketMan
    Dec 12 at 12:38






  • 1




    So you want to copy them? Are you just looking for a script that will run cp orig.pdf copy.pdf for each file? You've linked to an SO question with a lot of text and a lot of python, why is that relevant? Please edit and explain what you need.
    – terdon
    Dec 12 at 12:38








  • 1




    "The pdfminer error mentioned above": what is this error? How can we reproduce it so we can test our answers? If it is explained in the linked Stack Overflow question, then please reproduce the relevant information here.
    – terdon
    Dec 12 at 15:11














1












1








1


1





Consider the following procedure:



1) Open a pdf file using the (ubuntu) document viewer.



2) Goto File



3) Goto print



4) Choose print as file and check the mark "pdf"



Yes, I am printing a pdf as pdf file. I have to do this for a large collection of files. I would like to do this running a script at the terminal.



Maybe you think that this procedure does not make any sense at all, but it actually was the only safe way I found to deal with the issue considered here. This stackoverflow question shows a problem with pdf files the EOF marker is not found. When I do the procedure described above, I am able to solve this problem [This is not the solution presented in stackoverflow site, which does not work here.]



I would like to this automatically with all files that present this issue.



I know that I should build one script (.sh) to this, but I do not know how to proceed.



An example of the pdf file (1) with problems is here



The corrected pdf file (2) is here



The only difference between them is that I opened the first using the "ubuntu document viewer", I went to "File", "Print", "Print to File", "Output=pdf".



I want to make this automatically.



EDIT:



I do NOT want to merge the files.










share|improve this question















Consider the following procedure:



1) Open a pdf file using the (ubuntu) document viewer.



2) Goto File



3) Goto print



4) Choose print as file and check the mark "pdf"



Yes, I am printing a pdf as pdf file. I have to do this for a large collection of files. I would like to do this running a script at the terminal.



Maybe you think that this procedure does not make any sense at all, but it actually was the only safe way I found to deal with the issue considered here. This stackoverflow question shows a problem with pdf files the EOF marker is not found. When I do the procedure described above, I am able to solve this problem [This is not the solution presented in stackoverflow site, which does not work here.]



I would like to this automatically with all files that present this issue.



I know that I should build one script (.sh) to this, but I do not know how to proceed.



An example of the pdf file (1) with problems is here



The corrected pdf file (2) is here



The only difference between them is that I opened the first using the "ubuntu document viewer", I went to "File", "Print", "Print to File", "Output=pdf".



I want to make this automatically.



EDIT:



I do NOT want to merge the files.







printing pdf






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 12 at 19:11

























asked Dec 12 at 11:34









DanielTheRocketMan

3441314




3441314








  • 1




    Do you want to print them (on paper, using a printer) or "save them in another directory from terminal"?
    – terdon
    Dec 12 at 12:29










  • Save in another directory as pdf.
    – DanielTheRocketMan
    Dec 12 at 12:36










  • However, I do not want to copy them.
    – DanielTheRocketMan
    Dec 12 at 12:38






  • 1




    So you want to copy them? Are you just looking for a script that will run cp orig.pdf copy.pdf for each file? You've linked to an SO question with a lot of text and a lot of python, why is that relevant? Please edit and explain what you need.
    – terdon
    Dec 12 at 12:38








  • 1




    "The pdfminer error mentioned above": what is this error? How can we reproduce it so we can test our answers? If it is explained in the linked Stack Overflow question, then please reproduce the relevant information here.
    – terdon
    Dec 12 at 15:11














  • 1




    Do you want to print them (on paper, using a printer) or "save them in another directory from terminal"?
    – terdon
    Dec 12 at 12:29










  • Save in another directory as pdf.
    – DanielTheRocketMan
    Dec 12 at 12:36










  • However, I do not want to copy them.
    – DanielTheRocketMan
    Dec 12 at 12:38






  • 1




    So you want to copy them? Are you just looking for a script that will run cp orig.pdf copy.pdf for each file? You've linked to an SO question with a lot of text and a lot of python, why is that relevant? Please edit and explain what you need.
    – terdon
    Dec 12 at 12:38








  • 1




    "The pdfminer error mentioned above": what is this error? How can we reproduce it so we can test our answers? If it is explained in the linked Stack Overflow question, then please reproduce the relevant information here.
    – terdon
    Dec 12 at 15:11








1




1




Do you want to print them (on paper, using a printer) or "save them in another directory from terminal"?
– terdon
Dec 12 at 12:29




Do you want to print them (on paper, using a printer) or "save them in another directory from terminal"?
– terdon
Dec 12 at 12:29












Save in another directory as pdf.
– DanielTheRocketMan
Dec 12 at 12:36




Save in another directory as pdf.
– DanielTheRocketMan
Dec 12 at 12:36












However, I do not want to copy them.
– DanielTheRocketMan
Dec 12 at 12:38




However, I do not want to copy them.
– DanielTheRocketMan
Dec 12 at 12:38




1




1




So you want to copy them? Are you just looking for a script that will run cp orig.pdf copy.pdf for each file? You've linked to an SO question with a lot of text and a lot of python, why is that relevant? Please edit and explain what you need.
– terdon
Dec 12 at 12:38






So you want to copy them? Are you just looking for a script that will run cp orig.pdf copy.pdf for each file? You've linked to an SO question with a lot of text and a lot of python, why is that relevant? Please edit and explain what you need.
– terdon
Dec 12 at 12:38






1




1




"The pdfminer error mentioned above": what is this error? How can we reproduce it so we can test our answers? If it is explained in the linked Stack Overflow question, then please reproduce the relevant information here.
– terdon
Dec 12 at 15:11




"The pdfminer error mentioned above": what is this error? How can we reproduce it so we can test our answers? If it is explained in the linked Stack Overflow question, then please reproduce the relevant information here.
– terdon
Dec 12 at 15:11










1 Answer
1






active

oldest

votes


















2














Make sure you have cups-pdf installed and added as printer. Note pdf printer name. (Optional) Edit /etc/cups/cups-pdf.conf: uncomment and change the line where is says #Out /var/spool/cups-pdf/${USER} to the desired output directory.



Then restart CUPS: sudo systemctl restart cups



Now in order to print do:



SOURCEDIR="/path/to/source/pdfs"
for i in "$SOURCEDIR"
do
lpr -P <pdf printer name> "$i"
done


Now copy the files from the default output directory to the desired location, if you didn't edit cups-pdf.conf



Install poppler-utils and run pdfunite input1.pdf input2.pdf input3.pdf output.pdf.






share|improve this answer























  • There are about hundred pdfs
    – DanielTheRocketMan
    Dec 12 at 12:45










  • And you want to make them all 100 into one pdf?
    – spacelander
    Dec 12 at 12:47










  • No I want to print each pdf file as a file one by one.
    – DanielTheRocketMan
    Dec 12 at 15:00











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%2f1100290%2fsave-each-pdf-file-of-a-directory-as-another-pdf-operation-similar-to-print-a-p%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














Make sure you have cups-pdf installed and added as printer. Note pdf printer name. (Optional) Edit /etc/cups/cups-pdf.conf: uncomment and change the line where is says #Out /var/spool/cups-pdf/${USER} to the desired output directory.



Then restart CUPS: sudo systemctl restart cups



Now in order to print do:



SOURCEDIR="/path/to/source/pdfs"
for i in "$SOURCEDIR"
do
lpr -P <pdf printer name> "$i"
done


Now copy the files from the default output directory to the desired location, if you didn't edit cups-pdf.conf



Install poppler-utils and run pdfunite input1.pdf input2.pdf input3.pdf output.pdf.






share|improve this answer























  • There are about hundred pdfs
    – DanielTheRocketMan
    Dec 12 at 12:45










  • And you want to make them all 100 into one pdf?
    – spacelander
    Dec 12 at 12:47










  • No I want to print each pdf file as a file one by one.
    – DanielTheRocketMan
    Dec 12 at 15:00
















2














Make sure you have cups-pdf installed and added as printer. Note pdf printer name. (Optional) Edit /etc/cups/cups-pdf.conf: uncomment and change the line where is says #Out /var/spool/cups-pdf/${USER} to the desired output directory.



Then restart CUPS: sudo systemctl restart cups



Now in order to print do:



SOURCEDIR="/path/to/source/pdfs"
for i in "$SOURCEDIR"
do
lpr -P <pdf printer name> "$i"
done


Now copy the files from the default output directory to the desired location, if you didn't edit cups-pdf.conf



Install poppler-utils and run pdfunite input1.pdf input2.pdf input3.pdf output.pdf.






share|improve this answer























  • There are about hundred pdfs
    – DanielTheRocketMan
    Dec 12 at 12:45










  • And you want to make them all 100 into one pdf?
    – spacelander
    Dec 12 at 12:47










  • No I want to print each pdf file as a file one by one.
    – DanielTheRocketMan
    Dec 12 at 15:00














2












2








2






Make sure you have cups-pdf installed and added as printer. Note pdf printer name. (Optional) Edit /etc/cups/cups-pdf.conf: uncomment and change the line where is says #Out /var/spool/cups-pdf/${USER} to the desired output directory.



Then restart CUPS: sudo systemctl restart cups



Now in order to print do:



SOURCEDIR="/path/to/source/pdfs"
for i in "$SOURCEDIR"
do
lpr -P <pdf printer name> "$i"
done


Now copy the files from the default output directory to the desired location, if you didn't edit cups-pdf.conf



Install poppler-utils and run pdfunite input1.pdf input2.pdf input3.pdf output.pdf.






share|improve this answer














Make sure you have cups-pdf installed and added as printer. Note pdf printer name. (Optional) Edit /etc/cups/cups-pdf.conf: uncomment and change the line where is says #Out /var/spool/cups-pdf/${USER} to the desired output directory.



Then restart CUPS: sudo systemctl restart cups



Now in order to print do:



SOURCEDIR="/path/to/source/pdfs"
for i in "$SOURCEDIR"
do
lpr -P <pdf printer name> "$i"
done


Now copy the files from the default output directory to the desired location, if you didn't edit cups-pdf.conf



Install poppler-utils and run pdfunite input1.pdf input2.pdf input3.pdf output.pdf.







share|improve this answer














share|improve this answer



share|improve this answer








edited Dec 12 at 23:25

























answered Dec 12 at 12:41









spacelander

40227




40227












  • There are about hundred pdfs
    – DanielTheRocketMan
    Dec 12 at 12:45










  • And you want to make them all 100 into one pdf?
    – spacelander
    Dec 12 at 12:47










  • No I want to print each pdf file as a file one by one.
    – DanielTheRocketMan
    Dec 12 at 15:00


















  • There are about hundred pdfs
    – DanielTheRocketMan
    Dec 12 at 12:45










  • And you want to make them all 100 into one pdf?
    – spacelander
    Dec 12 at 12:47










  • No I want to print each pdf file as a file one by one.
    – DanielTheRocketMan
    Dec 12 at 15:00
















There are about hundred pdfs
– DanielTheRocketMan
Dec 12 at 12:45




There are about hundred pdfs
– DanielTheRocketMan
Dec 12 at 12:45












And you want to make them all 100 into one pdf?
– spacelander
Dec 12 at 12:47




And you want to make them all 100 into one pdf?
– spacelander
Dec 12 at 12:47












No I want to print each pdf file as a file one by one.
– DanielTheRocketMan
Dec 12 at 15:00




No I want to print each pdf file as a file one by one.
– DanielTheRocketMan
Dec 12 at 15:00


















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.





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%2faskubuntu.com%2fquestions%2f1100290%2fsave-each-pdf-file-of-a-directory-as-another-pdf-operation-similar-to-print-a-p%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

flock() on closed filehandle LOCK_FILE at /usr/bin/apt-mirror

Mangá

Eduardo VII do Reino Unido