op.annots.setProps

From PDF XChange PDF SDK
Jump to: navigation, search


Overview

The operation allows to set properties of the given annotations.

Parameters

Name Type Description
Input Array Array of IUnknown-based objects containing the IPXC_Annotation objects which will have their properties modified. Note that all of the annotations must belong to one document.
Output Array Not yet implemented.
Options Dictionary Dictionary with options of the operation.

Sample

01//C#
02private void SetAnnotationsProperties(PDFXEdit.IPXV_Document Doc, PDFXEdit.IPXV_Inst Inst)
03{
04    PDFXEdit.IPXS_Inst pSInt = (PDFXEdit.IPXS_Inst)Inst.GetExtension("PXS");
05    uint nWidgetAtom = pSInt.StrToAtom("Widget");
06    int nID = Inst.Str2ID("op.annots.setProps", false);
07    PDFXEdit.IOperation Op = Inst.CreateOp(nID);
08    PDFXEdit.ICabNode input = Op.Params.Root["Input"];
09    //Get widget annotations from the first page
10    PDFXEdit.IPXC_Page page = Doc.CoreDoc.Pages[0];
11    uint nPageCount = page.GetAnnotsCount();
12    for (uint i = 0; i < nPageCount; i++)
13    {
14        PDFXEdit.IPXC_Annotation annot = page.GetAnnot(i);
15        if (annot.Type == nWidgetAtom)
16        {
17            if ((annot.Field != null) && (annot.Field.Type == PDFXEdit.PXC_FormFieldType.FFT_Text))
18                input.Add().v = annot;
19        }
20    }
21    if (input.Count == 0)
22        return;
23    PDFXEdit.ICabNode options = Op.Params.Root["Options"];
24    options["ContentRotation"].v = 90;
25    options["MaskEx"].v = 0x00000400; // widgets will be modified
26    Op.Do();
27}
28 
29private void SetLineWidthProfile(PDFXEdit.IPXV_Document Doc, PDFXEdit.IPXV_Inst Inst)
30{
31    PDFXEdit.IPXS_Inst pSInt = (PDFXEdit.IPXS_Inst)Inst.GetExtension("PXS");
32    int nID = Inst.Str2ID("op.annots.setProps", false);
33    PDFXEdit.IOperation Op = Inst.CreateOp(nID);
34    PDFXEdit.ICabNode input = Op.Params.Root["Input"];
35    //Get widget annotations from the first page
36    PDFXEdit.IPXC_Page page = Doc.CoreDoc.Pages[0];
37    uint nPageCount = page.GetAnnotsCount();
38    for (uint i = 0; i < nPageCount; i++)
39    {
40        PDFXEdit.IPXC_Annotation annot = page.GetAnnot(i);
41        input.Add().v = annot;
42    }
43    if (input.Count == 0)
44        return;
45    PDFXEdit.ICabNode options = Op.Params.Root["Options"];
46    options["LineWidthProfile"].v = Inst.Str2ID("pencil.varProfile.5");
47    options["MaskEx"].v = 0x00008000;
48    Op.Do();
49}