This example shows how to draw one PDF into another. It takes a PDF document and creates a 'four-up' summary document by drawing four pages on each page of the new document.

 

   
Src
 
     

First we create an ABCpdf Doc object and read in our source document.

Set theSrc = Server.createobject("abcpdf3.doc")
theSrc.Read "c:\mypdfs\spaceshuttle.pdf"
theCount = theSrc.PageCount


   
Dest
 
     

Next we create a destination Doc object and set the MediaBox so that the page size will match that of the source document. We change the rect so that it occupies a quarter of the page with room to accomodate a small margin.

Set theDst = CreateObject("ABCpdf3.Doc")
theDst.MediaBox = theSrc.MediaBox
theDst.Rect = theDst.MediaBox
theDst.Rect.Magnify 0.5, 0.5
theDst.Rect.Inset 10, 10
theX = theDst.MediaBox.Width / 2
theY = theDst.MediaBox.Height / 2

 

   
Add
 
     

We go through every page in the source document drawing a framed copy of each page at a different position on our four-up document. Every fourth page we add a new page into our destination document.

For i = 1 To theCount
  theItem = i Mod 4
For i = 1 To theCount
  Select Case i Mod 4
    Case 1
      theDst.Page = theDst.AddPage()
      theDst.Rect.Position 10, theY + 10
    Case 2
      theDst.Rect.Position theX + 10, theY + 10
    Case 3
      theDst.Rect.Position 10, 10
    Case 0
      theDst.Rect.Position theX + 10, 10
  End Select
  theDst.AddImage theSrc, i
  theDst.FrameRect
Next

 

   
Save
 
     

Finally we save.

theDoc.Save "c:\mypdfs\fourup.pdf"

 

   
Results
 
     

We get the following output.


fourup.pdf [Page 1]

fourup.pdf [Page 2]

 

 

 

 

 

   

 

Browser Based Help. Published by chm2web software.