LinuxQuestions.org
Visit Jeremy's Blog.
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, 05: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 05:13 AM. Reason: error on first post
 
Old 01-15-2008, 09:07 AM   #2
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,453

Rep: Reputation: 446Reputation: 446Reputation: 446Reputation: 446Reputation: 446
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 05:04 PM
Convert Word Document to PDF liguorir Linux - Software 12 05-14-2013 11:38 AM
How to digitally sign a pdf document ssaigol Linux - Software 2 05-21-2005 04:15 AM
Unable to open PDF document !! majalee Linux - Software 5 08-03-2004 12:44 PM
How can I edit a pdf document? geraldomanaus Linux - Software 5 04-22-2003 10:28 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:48 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
Open Source Consulting | Domain Registration