I am adding an imported page to a new document and I would like to "crop" the page to smaller dimensions before adding it. I am unable to find any methods to do this.
Crop PDF Document
Re: Crop PDF Document
Support · Feb 17, 2006Hello,
In order to crop an existing PDF page, you create an ImportedPageContent out of the PDF (specifying the page you want to use), then crop that ImportedPageContents to the size you want (using Clip… properties) then you can create an ImportedPageData PageElement out of the ImportedPageContent and place the ImportedPageData on the page at whatever offset and scale you would like.
The following code demonstrates this functionality:
Document document = new Document();
Page page = new Page();
document.Pages.Add( page );
ImportedPageContents contents = new ImportedPageContents( MapPath( "PDFs/DocumentA.pdf" ), 1 );
contents.ClipBottom = 380;
contents.ClipLeft = 100;
contents.ClipRight = 100;
contents.ClipTop = 200;
page.Elements.Add( new ImportedPageData( contents, 0, 0, 1f ) );
document.DrawToWeb( this, "cropped.pdf" );
Thanks,
ceTe Software Support Team