op.annots.flatten
From PDF XChange PDF SDK
Overview
The operation allows to convert annotations into the pages content.
Parameters
Name | Type | Description |
---|---|---|
Input | Array | Array of IUnknown -based objects containing the IPXC_Annotation objects that need to be flattened. Also the IPXC_Document can be specified - that will mean that all of the annotations will be flattened. Note that all of the annotations must belong to one document.
|
Output | Array | Array of IUnknown -based objects containing the IPXC_Document which annotations were flattened. Not yet implemented.
|
Options | Dictionary | Dictionary with options of the operation. |
Sample
//C# private void FlattenSquareAnnotations(PDFXEdit.IPXV_Document Doc, PDFXEdit.PXV_Inst Inst) { PDFXEdit.IPXS_Inst pSInt = (PDFXEdit.IPXS_Inst)Inst.GetExtension("PXS"); uint nSquareAtom = pSInt.StrToAtom("Square"); int nID = Inst.Str2ID("op.annots.flatten", false); PDFXEdit.IOperation Op = Inst.CreateOp(nID); PDFXEdit.ICabNode input = Op.Params.Root["Input"]; // Filling the operation with the annotations that need to be flatten uint pagesCnt = Doc.CoreDoc.Pages.Count; for (uint i = 0; i < pagesCnt; i++) { PDFXEdit.IPXC_Page page = Doc.CoreDoc.Pages[i]; uint annotsCnt = page.GetAnnotsCount(); for (uint j = 0; j < annotsCnt; j++) { PDFXEdit.IPXC_Annotation annot = page.GetAnnot(j); //In our case it's square annotations if (annot.Type == nSquareAtom) input.Add().v = annot; } } PDFXEdit.ICabNode options = Op.Params.Root["Options"]; // Flattening non-printable annotations options["NonPrintableAction"].v = "Flatten"; // Ignore form fields options["FieldsAction"].v = "LeftAsIs"; Op.Do(); } private void FlattenAllAnnotationsOnFirst3Pages(PDFXEdit.IPXV_Document Doc, PDFXEdit.PXV_Inst Inst) { int nID = Inst.Str2ID("op.annots.flatten", false); PDFXEdit.IOperation Op = Inst.CreateOp(nID); PDFXEdit.ICabNode input = Op.Params.Root["Input"]; // If we add document as an input - it means that we'll flatten all of the annotations input.Add().v = Doc; PDFXEdit.ICabNode options = Op.Params.Root["Options"]; // Going through first 3 pages options["PagesRange.Type"].v = "Exact"; options["PagesRange.Text"].v = "1-3"; // Flattening non-printable annotations options["NonPrintableAction"].v = "Flatten"; // Ignore form fields options["FieldsAction"].v = "LeftAsIs"; Op.Do(); }