This sounds great like a great idea. Problem is if say, Appendix A (in
A.pdf) is stored in page 16 in one document and page 19 in another (ie.
Appendix A may not necessary be in one particular page), how would I insert
the content of B.pdf into page 17 and 20 respectively? Would I need to
convert A.pdf to Latex first to work out where Appendix A is located? If so,
would you or anyone else know how to do this by any chance?

As you can see, I am totally clueless about Latex.

Thanks,
--SH


-----Original Message-----
From: Angus Lees [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, 21 May 2002 3:31 PM
To: Hartono, Susanto
Cc: '[EMAIL PROTECTED]'
Subject: Re: How to append a PDF file into another PDF file


At Tue, 21 May 2002 13:36:08 +1000, Susanto Hartono wrote:
> Is it possible to append the content of one pdf file into another without
> using the commercial version of Adobe Acrobat? I am trying to insert the
> content of one pdf file into a particular section of another. For example
if
> A has multiple headings as shown below, how do I insert the content of B
> immediately after Appendix 1 - without affecting the overall content? I'd
> like to script this if possible as there are quite a number of pdf files
> that have to be done.
> 
> [ File A ]
> 
> Heading 1
>   Content
> Heading 2
>   Content
> Appendix 1
>   >> Insert content from B <<
> Appendix 2
>   Content 

as silly as it might sound, i tend to use pdflatex for most of my pdf
manipulations:


grab the "pdfpages" package from your nearest CTAN mirror:
 
ftp://ctan.unsw.edu.au/tex-archive/macros/latex/contrib/supported/pdfpages.t
ar.gz
 unpack
 latex pdfpages.ins
 if you want the documentation, do "latex pdfpages.dtx" 3 times


export TEXINPUTS="/path/to/pdfpages//:$TEXINPUTS"


put this in (eg) "combine.tex":

\documentclass{article}
% above must be first line in file

\usepackage{pdfpages}

\newcounter{nextpage}
\setcounter{nextpage}{\insertafter}
\stepcounter{nextpage}

\begin{document}
\includepdfmerge{\filea, -\insertafter, \fileb, -, \filea, \thenextpage-}
\end{document}


then do:

 pdflatex --interaction=batchmode \
  '\def\filea{A.pdf}\def\fileb{B.pdf}\def\insertafter{16}\input combine.tex'

 mv combine.pdf AB.pdf

to (for example) combine B.pdf into A.pdf after A.pdf's page 16.


you probably want to put that last bit in a shell script loop or
something:

 while read A B page; do
   pdflatex --interaction=batchmode \
     "\\def\\filea{$A}\\def\\fileb{$B}\\def\\insertafter{$page}\\input
combine.tex"
   mv combine.pdf "${A%.pdf}_${B%.pdf}.pdf"
 done < input_file

where input_file contains lines like:
 file1.pdf file2.pdf 16
 anotherfile.pdf yafile.pdf 7
 (etc)


(i'm sure someone who has actually read the TeXbook knows a much
better way to specify parameters on the command line..)

-- 
 - Gus
-- 
SLUG - Sydney Linux User's Group - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug

Reply via email to