Input file for pdftk

If none of the specific sub-forums seem right for your thread, ask here.
Message
Author
CwF
Global Moderator
Global Moderator
Posts: 3073
Joined: 2018-06-20 15:16
Location: Colorado
Has thanked: 63 times
Been thanked: 254 times

Re: Input file for pdftk

#21 Post by CwF »

PDA123 wrote: 2023-01-07 02:26 $ pdftk $("cat files.txt") cat output out.pdf
bash: cat files.txt: command not found
bash: $: command not found
Yep, I was wrong, I'm hungry.
$ echo $(cat files.txt)
that looks correct? I'm not familiar with the command, but looks to be returning correct paths.
Post the full error return with the single quoted filename and space corrected. The first full return post did show it splitting that one filename.
Mottainai

PDA123
Posts: 78
Joined: 2021-04-24 01:55
Been thanked: 1 time

Re: Input file for pdftk

#22 Post by PDA123 »

I quit. This just isn't working.

Thank you for the help....it was a good try!

User avatar
ramack
Posts: 500
Joined: 2008-01-28 15:31
Location: Centennial, CO
Has thanked: 6 times

Re: Input file for pdftk

#23 Post by ramack »

Glad to see you're able to utilize the idea. One of the many benefits and power of our OS!

I'm a mechanical engineer, but usually end up getting involve in electrical stuff too. My position with the company I was working at in 2011 was an electrical engineer. I was compiling a two large production manuals for machines that we were building. I organized the "chapters" in directories to help me keep stuff straight. Since it was an engineering production manual, it had a mix of text, pictures, schematics and part drawings. And because of this assortment, there were also pages that were 8.5x11 portrait and 11x17 landscape.

Since I ended up having multiple directories as sources for the manual, I wrote a bash script that drilled down into each directory for info in compiling the "final" PDF. I have long since left that company (gosh...that's another story, ha) and while I still have hard and soft copies of the manuals, I don't think I managed to copy the scripts and ancillary info before I left. Hindsight, I probably I coulda woulda shoulda kept that desktop that I had there. No one there knew what Linux is and that desktop most likely just got shelved somewhere. I'll see if I can find info that I may have copied of the HD and repost the scripts.
homemade AMD64, Acer AspireOne 150, Asus eeePC 900, i386; Testing
i386,Dell Vostro 1000 AMD64, Dell Inspiron 1100; Sid
XFCE on all.

User avatar
ramack
Posts: 500
Joined: 2008-01-28 15:31
Location: Centennial, CO
Has thanked: 6 times

Re: Input file for pdftk

#24 Post by ramack »

PDA123 wrote: 2023-01-07 13:34 I quit. This just isn't working.

Thank you for the help....it was a good try!
Don't quit! One good way of learning is by 'fixin' stuff that isn't working.
homemade AMD64, Acer AspireOne 150, Asus eeePC 900, i386; Testing
i386,Dell Vostro 1000 AMD64, Dell Inspiron 1100; Sid
XFCE on all.

User avatar
ramack
Posts: 500
Joined: 2008-01-28 15:31
Location: Centennial, CO
Has thanked: 6 times

Re: Input file for pdftk

#25 Post by ramack »

So...looks like I didn't use a script after all. Just a simple CLI command. Most of the effort and organization is in a source text file, manual_page_order.txt and the directories that contain the PDFs that were created from OpenOffice(pre-LibreOffice), Draftsight and Base.

From my readme:
This readme.txt explains how to combine/merge all the individual manual PDFs in the final copy.
After all the individual PDFs have been created, group them accordingly in manual_page_order.txt

Then from the CLI:
$ pdftk $(< manual_page_order.txt) cat output FINAL/ue01_elect_manual_rev04.pdf

manual_page_order.txt 👇

Code: Select all

ue01_elect_manual_toc8.pdf
blank_letter.pdf

pg_0001.pdf
blank_letter.pdf
revision_sheet.pdf
blank_letter.pdf
ue01_power_panel_assembly.pdf
blank_letter.pdf
/home/ramack/Documents/ue01/current_mech_dwg_pdf/01-PPN-01-00.pdf
blank_letter.pdf
ue01_power_panel_bom.pdf
blank_letter.pdf
ue01_back_panel_assembly.pdf
blank_letter.pdf
/home/ramack/Documents/ue01/current_mech_dwg_pdf/01-BPN-01-00.pdf
blank_letter.pdf
ue01_back_panel_bom.pdf
blank_letter.pdf
ue01_enclosure_assembly_partial.pdf

pg_0002.pdf
revision_sheet.pdf
/home/ramack/Documents/ue01/current_mech_dwg_pdf/01-BPN-02-00.pdf
/home/ramack/Documents/ue01/current_mech_dwg_pdf/01-BPN-03-00.pdf
/home/ramack/Documents/ue01/current_mech_dwg_pdf/01-BPN-04-00.pdf
/home/ramack/Documents/ue01/current_mech_dwg_pdf/01-BPN-05-00.pdf
/home/ramack/Documents/ue01/current_mech_dwg_pdf/01-PPN-02-00.pdf
/home/ramack/Documents/ue01/current_mech_dwg_pdf/01-PPN-03-00.pdf
/home/ramack/Documents/ue01/current_mech_dwg_pdf/01-PPN-04-00.pdf

pg_0003.pdf
cable_bag_tag.pdf
ue01_cable_checklist_oriental_remotemonitor_autoload_r00.pdf
ue01_cable_checklist_oriental_remotemonitor_r00.pdf
vendor_pn_query_bom_auto.pdf
vendor_pn_query_bom_tilt.pdf

pg_0004.pdf
revision_sheet.pdf
pg_0005.pdf
/home/ramack/Documents/ue01/current_cable_pdf/load_tilttable/01-LTT-01-01.pdf
/home/ramack/Documents/ue01/current_cable_pdf/load_tilttable/01-LTT-11-01.pdf
/home/ramack/Documents/ue01/current_cable_pdf/load_tilttable/01-LTT-12-01.pdf
/home/ramack/Documents/ue01/current_cable_pdf/load_tilttable/01-LTT-99-01.pdf
pg_0006.pdf
/home/ramack/Documents/ue01/current_cable_pdf/load_tilttable/01-LTT-01-02.pdf
/home/ramack/Documents/ue01/current_cable_pdf/load_tilttable/01-LTT-11-02.pdf
/home/ramack/Documents/ue01/current_cable_pdf/load_tilttable/01-LTT-12-02.pdf
/home/ramack/Documents/ue01/current_cable_pdf/load_tilttable/01-LTT-99-02.pdf

pg_0007.pdf
revision_sheet.pdf
/home/ramack/Documents/ue01/current_cable_pdf/internal/*.pdf

pg_0008.pdf revision_sheet.pdf 
/home/ramack/Documents/ue01/current_cable_pdf/inter_panel/*.pdf

pg_0009.pdf
revision_sheet.pdf
/home/ramack/Documents/ue01/current_cable_pdf/external/*.pdf

pg_0010.pdf
revision_sheet.pdf
/home/ramack/Documents/ue01/assembly_documentation/assy_man_pdf/ue01_input_output_relay_designation.pdf
/home/ramack/Documents/ue01/current_wiring_diagrams_pdf/*.pdf
The next tricky part was getting this printed. The company had a great MFC that no one seemed to know how to use except for copying and printing simple stuff. What was odd is that the CUPS drivers ended up working better than the Windows drivers and people would email stuff to me to have it printed, ha.
homemade AMD64, Acer AspireOne 150, Asus eeePC 900, i386; Testing
i386,Dell Vostro 1000 AMD64, Dell Inspiron 1100; Sid
XFCE on all.

User avatar
ramack
Posts: 500
Joined: 2008-01-28 15:31
Location: Centennial, CO
Has thanked: 6 times

Re: Input file for pdftk

#26 Post by ramack »

PDA123 wrote: 2023-01-06 22:38 Back from the dead....

This topic has been very helpful. I'm having one problem. If the files listed in the array are located in the folder where there pdftk command is executed then they are nicely cat'd into the output file.

However, in my case, if the files to be cat'd into the pdf output file are located in another folder I have no idea how to exactly list them in the array.txt file. Even when I use the following format I always get the same error message- file not found.

Example of one of the array.txt files- /home/Mine/My Documents/The Three Stooges Episodes.pdf

Even if I use this format the same error message appears (file not found);

/home/Mine/My Documents/The\ Three\ Stooges\ Episodes.pdf

I've tried a lot of variations of the filename to no success.

Any ideas?

P.S. I don't need a list of Stooges episodes- I have them memorized.
You might be running into something that Bash has trouble with, which is white spaces. That is probably why I used underscores in directory and filenames. Although I did find the files on the external drive that I copied to, it's beginning to fail, so I'm backing it up to a NAS before it completely pukes. Once the backup is done, I can see what other notes and info I have on the drive.

When doing other file conversion and manipulation, I've had problems with spaces and usually ended up putting into the script a couple additional lines that removed them before continuing with the operation of whatever was being done.
homemade AMD64, Acer AspireOne 150, Asus eeePC 900, i386; Testing
i386,Dell Vostro 1000 AMD64, Dell Inspiron 1100; Sid
XFCE on all.

Post Reply