Draw a page from one PDF document onto the current page of this document.




int AddImageDoc(Doc doc, int page, XRect rect)
int AddImageDoc(Doc doc, int page, XRect rect, bool copyAnnotations)
int AddImageDoc(Doc doc, int page, XRect rect, double alpha)

[Visual Basic]
Function AddImageDoc(doc As Doc, page As Integer, rect As XRect) As Integer
Function AddImageDoc(doc As Doc, page As Integer, rect As XRect, copyAnnotations As Boolean) As Integer
Function AddImageDoc(doc As Doc, page As Integer, rect As XRect, copyAnnotations As Boolean, alpha As Double) As Integer



Name Description

The document to be used as the source.


The page you want drawn. Use one to indicate the first page.


The portion of the page you want drawn. Pass null to specify the entire page.

copyAnnotations Whether to copy fields and annotations - default false.
alpha The level of alpha to apply to the drawn page from transparent through to fully opaque (0 to 255).
return The ID of the newly added Image Object.




Draw a page from one PDF document onto the current page of this document returning the ID of the newly added object.

The page is scaled to fill the current Rect. It is transformed using the current Transform.

Many field and annotation types can only exist as a simple rectangle with sides parallel to the page borders. For this reason you should be cautious about the transforms you use when specifying that annotations should be copied. A transform which involves scale and translation will be fine but one involving rotation and skew factors may result in unusual output if the field or annotation does not support this combination.

The SaveOptions.Refactor setting determines whether duplicate and redundant objects are eliminated. The SaveOptions.Preflight setting determines whether objects in the destination document are validated before this operation is performed.

Unless the document and the pages are big in terms of memory use and have many common objects, it is faster to disable SaveOptions.Refactor and SaveOptions.Preflight for adding the pages and enable them for saving the document.

Pages may be rotated. As such, when drawing one page onto another, you may wish to copy the Page.Rotation from the source page to the destination page. More complex example code to de-rotate a page may be found under the documentation for the Page.Rotation.




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.

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

Doc theSrc = new Doc();
int theCount = theSrc.PageCount;

[Visual Basic]
Dim theSrc As Doc = New Doc()
Dim theCount As Integer = theSrc.PageCount

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.

Doc theDst = new Doc();
theDst.MediaBox.String = theSrc.MediaBox.String;
theDst.Rect.String = theDst.MediaBox.String;
theDst.Rect.Magnify(0.5, 0.5);
theDst.Rect.Inset(10, 10);
double theX, theY;
theX = theDst.MediaBox.Width / 2;
theY = theDst.MediaBox.Height / 2;

[Visual Basic]
Dim theDst As Doc = New Doc()
theDst.MediaBox.String = theSrc.MediaBox.String
theDst.Rect.String = theDst.MediaBox.String
theDst.Rect.Magnify(0.5, 0.5)
theDst.Rect.Inset(10, 10)
Dim theX As Double,theY As Double
theX = theDst.MediaBox.Width / 2
theY = theDst.MediaBox.Height / 2

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 (int i = 1; i <= theCount; i++) {
  switch (i % 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);
  theDst.AddImageDoc(theSrc, i, null);

[Visual Basic]
For i As Integer = 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.AddImageDoc(theSrc, i, Nothing)

Finally we save.

// finished

[Visual Basic]
' finished

We get the following output.

fourup.pdf - [Page 1]

fourup.pdf - [Page 2]