Wednesday, April 24, 2024
 Popular · Latest · Hot · Upcoming
1
rated 0 times [  1] [ 0]  / answers: 1 / hits: 938  / 3 Years ago, thu, july 1, 2021, 12:39:29

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.


More From » printing

 Answers
3

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.


[#6567] Friday, July 2, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
breadoules

Total Points: 212
Total Questions: 118
Total Answers: 120

Location: Dominica
Member since Mon, Jun 22, 2020
4 Years ago
;