op.annots.flatten
From PDF XChange PDF SDK
(→Sample) |
|||
(One intermediate revision by one other user not shown) | |||
Line 30: | Line 30: | ||
private void FlattenSquareAnnotations(PDFXEdit.IPXV_Document Doc, PDFXEdit.PXV_Inst Inst) | private void FlattenSquareAnnotations(PDFXEdit.IPXV_Document Doc, PDFXEdit.PXV_Inst Inst) | ||
{ | { | ||
− | PDFXEdit.IPXS_Inst pSInt = (PDFXEdit.IPXS_Inst) | + | PDFXEdit.IPXS_Inst pSInt = (PDFXEdit.IPXS_Inst)Inst.GetExtension("PXS"); |
uint nSquareAtom = pSInt.StrToAtom("Square"); | uint nSquareAtom = pSInt.StrToAtom("Square"); | ||
− | int nID = | + | int nID = Inst.Str2ID("op.annots.flatten", false); |
− | PDFXEdit.IOperation Op = | + | PDFXEdit.IOperation Op = Inst.CreateOp(nID); |
PDFXEdit.ICabNode input = Op.Params.Root["Input"]; | PDFXEdit.ICabNode input = Op.Params.Root["Input"]; | ||
− | //Filling the operation with the annotations that need to be flatten | + | // Filling the operation with the annotations that need to be flatten |
− | for (uint i = 0; i < | + | uint pagesCnt = Doc.CoreDoc.Pages.Count; |
+ | for (uint i = 0; i < pagesCnt; i++) | ||
{ | { | ||
PDFXEdit.IPXC_Page page = Doc.CoreDoc.Pages[i]; | PDFXEdit.IPXC_Page page = Doc.CoreDoc.Pages[i]; | ||
− | uint | + | uint annotsCnt = page.GetAnnotsCount(); |
− | for (uint j = 0; j < | + | for (uint j = 0; j < annotsCnt; j++) |
{ | { | ||
PDFXEdit.IPXC_Annotation annot = page.GetAnnot(j); | PDFXEdit.IPXC_Annotation annot = page.GetAnnot(j); | ||
Line 49: | Line 50: | ||
} | } | ||
PDFXEdit.ICabNode options = Op.Params.Root["Options"]; | PDFXEdit.ICabNode options = Op.Params.Root["Options"]; | ||
− | + | // Flattening non-printable annotations | |
− | + | ||
− | //Flattening non-printable annotations | + | |
options["NonPrintableAction"].v = "Flatten"; | options["NonPrintableAction"].v = "Flatten"; | ||
− | //Ignore form fields | + | // Ignore form fields |
options["FieldsAction"].v = "LeftAsIs"; | options["FieldsAction"].v = "LeftAsIs"; | ||
+ | |||
Op.Do(); | Op.Do(); | ||
} | } | ||
− | private void | + | 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); | |
− | int nID = | + | |
− | PDFXEdit.IOperation Op = | + | |
PDFXEdit.ICabNode input = Op.Params.Root["Input"]; | PDFXEdit.ICabNode input = Op.Params.Root["Input"]; | ||
− | //If we add document as an input - it means that we'll flatten all of the annotations | + | // If we add document as an input - it means that we'll flatten all of the annotations |
input.Add().v = Doc; | input.Add().v = Doc; | ||
PDFXEdit.ICabNode options = Op.Params.Root["Options"]; | PDFXEdit.ICabNode options = Op.Params.Root["Options"]; | ||
− | //Going through first 3 pages | + | // Going through first 3 pages |
options["PagesRange.Type"].v = "Exact"; | options["PagesRange.Type"].v = "Exact"; | ||
options["PagesRange.Text"].v = "1-3"; | options["PagesRange.Text"].v = "1-3"; | ||
− | //Flattening non-printable annotations | + | // Flattening non-printable annotations |
options["NonPrintableAction"].v = "Flatten"; | options["NonPrintableAction"].v = "Flatten"; | ||
− | //Ignore form fields | + | // Ignore form fields |
options["FieldsAction"].v = "LeftAsIs"; | options["FieldsAction"].v = "LeftAsIs"; | ||
+ | |||
Op.Do(); | Op.Do(); | ||
} | } | ||
</pre> | </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(); }