op.annots.flatten
From PDF XChange PDF SDK
(→Sample) |
|||
(2 intermediate revisions by one other user not shown) | |||
Line 15: | Line 15: | ||
| class="op_param_name" | Input | | class="op_param_name" | Input | ||
| style="text-align:center" | Array | | style="text-align:center" | Array | ||
− | | Array of <code>IUnknown</code>-based objects containing the [[PXV:IPXC_Annotation|IPXC_Annotation]] objects that need to be flattened. Note that all of the annotations must belong to one document. | + | | Array of <code>IUnknown</code>-based objects containing the [[PXV:IPXC_Annotation|IPXC_Annotation]] objects that need to be flattened. Also the [[PXV:IPXC_Document|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. |
|- | |- | ||
| class="op_param_name" | Output | | class="op_param_name" | Output | ||
Line 25: | Line 25: | ||
| Dictionary with options of the operation. | | Dictionary with options of the operation. | ||
|} | |} | ||
+ | |||
+ | == Sample == | ||
+ | <pre class="brush:c#">//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(); | ||
+ | } | ||
+ | </pre> |
Latest revision as of 10:14, 26 July 2016
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(); }