Merging PDF Files

L

lists.ryan

Hi All.

I would like to take 2 pdf files that i have created and combine them
into a single pdf.

Is this possible ?

Thanks in advance.
Ryan
 
D

Dr.Ruud

(e-mail address removed) schreef:
I would like to take 2 pdf files that i have created and combine them
into a single pdf.

Is this possible ?


I once did something like this with awk. It combines 2 documents,
renumbering the pages, so that the pages of the two documents become
interleaved. With two-sided printing, page 1 of doc 1 and page 1 of doc
2, printed on the same piece of paper. The resulting PDF is also useful
as a backup, for browsing.

Let me search...

My PDF-sources were created by cygwin/ps2pdf, the PS-sources were
createted by printing-to-file with an HP Laserjet PS driver on a Windows
system.

Wo, this is old:

### cln.awk:

BEGIN { FS = "\001" }
{ print $2 }


### ltf.awk:

BEGIN {
FS=" "
P = 0
L = 0
}

/^%%Trailer/, /^\004%-12345X/ { next }

/^%%Page:.*/ {
L = 1
P = 2*($3-1)+1
printf( "%04d%04d\001", P, L)
print $1 " " P " " P
next
}

/^\(%%\[Page:.*/ {
++L
printf( "%04d%04d\001", P, L)
$2 = P "]%%)"
print
next
}

{
++L
printf( "%04d%04d\001", P, L)
print
}


### rgt.awk:

BEGIN {
FS=" "
P = 0
L = 0
M = 0
}

/^\033%-12345X@PJL/, /^%%EndSetup/ { next }

/^%%Page:.*/ {
P = 2 * $3
M = P
L = 1
printf( "%04d%04d\001", P, L)
print $1 " " P " " P
next
}

/^\(%%\[Page:.*/ {
++L
printf( "%04d%04d\001", P, L)
print $1 " " P "]%%) ="
next
}

/^%%Pages:.*/ {
++L
printf( "%04d%04d\001", P, L)
$2 = M
print
next
}

{
++L
printf( "%04d%04d\001", P, L)
print
}
 
M

Mark

Hi All.

I would like to take 2 pdf files that i have created and combine them
into a single pdf.

Is this possible ?

Thanks in advance.
Ryan

This seems to work for me:

use strict ;
use warnings ;
use PDF::API2;


my $pdf = PDF::API2->new;
my $nextpage = 1 ;

foreach (@ARGV) {
my $old = PDF::API2->open($_) ;
for (my $ii=1; $ii <= $old->pages ; $ii++) {
$pdf->importpage($old,$ii,$nextpage) ;
$nextpage++ ;
}
}

$pdf->saveas("new.pdf");
 
L

lists.ryan

Mark - thanks soo much...

That works great !!...

Thanks to all others that posted.

Ryan.
 
M

Michele Dondi

I would like to take 2 pdf files that i have created and combine them
into a single pdf.

In *addition* to the other answers you got, the pdfpages package for
pdfLaTeX can also do that. Of course you need a (La)TeX installation,
and that particular package - which you may already have.


PS: of course this answer has nothing to do with Perl, unless you're
using PerlTeX, that is - in which case it would have to do with it in
a marginal way...


Michele
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,181
Messages
2,570,969
Members
47,536
Latest member
VeldaYoung

Latest Threads

Top