DrawPageOnPage
IPDFDocument4 :: General document management :: Common

See Also Example
Collapse All

The function draws source page into a destination page.

Syntax

HRESULT DrawPageOnPage (
LONG srcPageIndex,
LONG destPageIndex,
FLOAT left,
FLOAT top,
FLOAT width,
FLOAT height
)
Parameters
srcPageIndex
Index of the source page

destPageIndex
Index of the destination page

left
The x-coordinate, in pixels, of the upper-left corner of the destination rectangle

top
The y-coordinate, in pixels, of the upper-left corner of the destination rectangle

width
The width, in pixels, of the destination rectangle

height
The height, in pixels, of the destination rectangle

Return value
If successful, this method returns S_OK. If it fails, this method should return one of the error values.

Remarks

The function groups several pages in one page. The function may combine 2, 4, or 8 pages in a single page, for example.

Example

Combining 4 pages in a single page

Delphi
[copy to clipboard]
{ PDF object is supposed to be created }
{ PDF file contains 4 pages A4}
PDF.Open('4pagesA4.pdf', '');

PDF.NewPage;
PDF.PageSize := pfA4; { set any page size here }
	   
PDF.CurrentPage := 4; { index of new page }
height := PDF.PageHeight;
width := PDF.PageWidth;

PDF.DrawPageOnPage(0, 4, 0.0, 0.0, width/2, height/2);
PDF.DrawPageOnPage(1, 4, width/2, 0.0, width/2, height/2);
PDF.DrawPageOnPage(2, 4, 0.0, height/2, width/2, height/2);
PDF.DrawPageOnPage(3, 4, width/2, height/2, width/2, height/2);

PDF.SaveToFile('result.pdf', true);
C/C++
[copy to clipboard]
// PDF object is supposed to be created 
// PDF file contains 4 pages A4
PDF->Open("4pagesA4.pdf", "");

PDF->NewPage();
PDF->PageSize = pfA4; // set any page size here 
	   
PDF->CurrentPage = 4; // index of new page 
long height = PDF->PageHeight;
long width = PDF->PageWidth;

PDF->DrawPageOnPage(0, 4, 0.0, 0.0, width/2, height/2);
PDF->DrawPageOnPage(1, 4, width/2, 0.0, width/2, height/2);
PDF->DrawPageOnPage(2, 4, 0.0, height/2, width/2, height/2);
PDF->DrawPageOnPage(3, 4, width/2, height/2, width/2, height/2);

PDF->SaveToFile("result.pdf", true);
C#
[copy to clipboard]
// PDF object is supposed to be created 
// PDF file contains 4 pages A4
PDF.Open("4pagesA4.pdf", "");

PDF.NewPage();
PDF.PageSize = pfA4; // set any page size here 
	   
PDF.CurrentPage = 4; // index of new page 
long height = PDF.PageHeight;
long width = PDF.PageWidth;

PDF.DrawPageOnPage(0, 4, 0.0, 0.0, width/2, height/2);
PDF.DrawPageOnPage(1, 4, width/2, 0.0, width/2, height/2);
PDF.DrawPageOnPage(2, 4, 0.0, height/2, width/2, height/2);
PDF.DrawPageOnPage(3, 4, width/2, height/2, width/2, height/2);

PDF.SaveToFile("result.pdf", true);
Visual Basic
[copy to clipboard]
' PDF object is supposed to be created 
' PDF file contains 4 pages A4
PDF.Open "4pagesA4.pdf", ""

PDF.NewPage
PDF.PageSize = pfA4 ' set any page size here 
	   
PDF.CurrentPage = 4 ' index of new page 
height = PDF.PageHeight
width = PDF.PageWidth

PDF.DrawPageOnPage 0, 4, 0.0, 0.0, width/2, height/2
PDF.DrawPageOnPage 1, 4, width/2, 0.0, width/2, height/2
PDF.DrawPageOnPage 2, 4, 0.0, height/2, width/2, height/2
PDF.DrawPageOnPage 3, 4, width/2, height/2, width/2, height/2

PDF.SaveToFile "result.pdf", true

See Also

Reference