op.document.cropPages

From PDF XChange PDF SDK
Jump to: navigation, search


Overview

The operation allows to change the crop box of the document's pages.

Parameters

Name Type Description
Input IUnknown IUnknown-based object containing the IPXC_Document which pages will be cropped.
Output IUnknown IUnknown-based object containing the IPXC_Document which pages were cropped.
Options Dictionary Dictionary with options of the operation.

Sample

01//C#
02private void RemoveWhiteSpaces(PDFXEdit.IPXV_Document pDoc, PDFXEdit.PXV_Inst pInst)
03{
04    if (pDoc == null)
05        return;
06    int nID = pInst.Str2ID("op.document.cropPages", false);
07    PDFXEdit.IOperation Op = pInst.CreateOp(nID);
08    PDFXEdit.ICabNode input = Op.Params.Root["Input"];
09    input.v = pDoc;
10    PDFXEdit.ICabNode options = Op.Params.Root["Options"];
11    options["Flags"].v = 1024 | 2048; //Remove white spaces
12    Op.Do();
13}
14 
15private void CropByOffsets(PDFXEdit.IPXV_Document pDoc, PDFXEdit.PXV_Inst pInst)
16{
17    if (pDoc == null)
18        return;
19    int nID = pInst.Str2ID("op.document.cropPages", false);
20    PDFXEdit.IOperation Op = pInst.CreateOp(nID);
21    PDFXEdit.ICabNode input = Op.Params.Root["Input"];
22    input.v = pDoc;
23    PDFXEdit.ICabNode options = Op.Params.Root["Options"];
24    options["Flags"].v = 2; //Crop Box
25    //Specifying offsets
26    options["IsOffset"].v = true;
27    options["CropBox.top"].v = 50;
28    options["CropBox.left"].v = 50;
29    options["CropBox.right"].v = 50;
30    options["CropBox.bottom"].v = 50;
31    Op.Do();
32}