LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-15-2008, 06:12 AM   #1
zest n zeal
LQ Newbie
 
Registered: May 2007
Posts: 18

Rep: Reputation: 0
Using pdftk to get all first pages of many pdf's into one pdf document


Hallo all,

I have about 100 randomly named pdfs in a directory and I wish to compile a document consisting of the first page of every one.


I normally use pdftk with a command like this:

pdftk A=first.pdf B=second.pdf C=third.pdf cat A1 B1 C1 output combined_firstpages.pdf

Could you please help me with the correct syntax to get output from

ls *.pdf

into that command? I been trying with the 'read' command which is what I normally use in this kind of circumstance but it just ain't working and I currently feel as if my head is going to explode.

many thanks to anyone who can help sort this.

Adam

Last edited by zest n zeal; 01-15-2008 at 06:13 AM. Reason: error on first post
 
Old 01-15-2008, 10:07 AM   #2
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,267

Rep: Reputation: 298Reputation: 298Reputation: 298
Hi

pdftk is not very good for this task. The handles can be only one letter and must be an uppercase letter, so only A-Z is possible.

But it can be done by making a temporary directory, extract page 1 of every PDF into a separate file in that directory, and then join all those PDF files into a big one. Here is a little script that does the job:

Code:
#!/bin/sh

#Set the filename on the line below:
DESTINATION="firstpages.pdf"

#Here is the temporary directory:
tempdir="/tmp/pdfpage1"
mkdir $tempdir
for name in *.pdf ; do
        pdftk "A=$name" cat A1 output "$tempdir/$name"
done
pdftk $tempdir/*.pdf cat output "$DESTINATION"
rm -r $tempdir
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Extract pages from a pdf document sn68 Linux - Desktop 9 08-28-2015 06:04 PM
Convert Word Document to PDF liguorir Linux - Software 12 05-14-2013 12:38 PM
How to digitally sign a pdf document ssaigol Linux - Software 2 05-21-2005 05:15 AM
Unable to open PDF document !! majalee Linux - Software 5 08-03-2004 01:44 PM
How can I edit a pdf document? geraldomanaus Linux - Software 5 04-22-2003 11:28 AM


All times are GMT -5. The time now is 10:41 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration