IPXC_Page::GetContent Method
From PDF XChange PDF SDK
m (Automatic page editing by robot) |
|||
(5 intermediate revisions by one other user not shown) | |||
Line 2: | Line 2: | ||
[[Category:Editor]] | [[Category:Editor]] | ||
{{#customTitle:IPXC_Page::GetContent Method}} | {{#customTitle:IPXC_Page::GetContent Method}} | ||
− | {{#parentPage:PXV:IPXC_Page#Methods|GetContent | + | {{#parentPage:PXV:IPXC_Page#Methods|GetContent|method}} |
{{ToReview}} | {{ToReview}} | ||
Line 8: | Line 8: | ||
== Syntax == | == Syntax == | ||
− | <pre class="brush:cpp;gutter:false">HRESULT GetContent([in] PXC_ContentAccessMode | + | <pre class="brush:cpp;gutter:false">HRESULT GetContent([in] PXC_ContentAccessMode nKMode, |
− | [out, retval] IPXC_Content** | + | [out, retval] IPXC_Content** pContent);</pre> |
== Parameters == | == Parameters == | ||
− | ; | + | ;nKMode |
:[in] [[PXV:PXC_ContentAccessMode|Access mode]] of the resulting content. | :[in] [[PXV:PXC_ContentAccessMode|Access mode]] of the resulting content. | ||
− | ; | + | ;pContent |
:[out, retval] Pointer to [[PXV:IPXC_Content|IPXC_Content]] containing the resulting page content. | :[out, retval] Pointer to [[PXV:IPXC_Content|IPXC_Content]] containing the resulting page content. | ||
== Return Value == | == Return Value == | ||
Returns S_OK if operation was successful or error code in other cases. | Returns S_OK if operation was successful or error code in other cases. | ||
+ | |||
+ | == Sample == | ||
+ | <pre class="brush:c#">//C# | ||
+ | private void SetContentColor(PDFXEdit.IPXV_Document Doc, PDFXEdit.IPXV_Inst Inst) | ||
+ | { | ||
+ | if (Doc == null) | ||
+ | return; | ||
+ | //Creating contentItems.setProps operation | ||
+ | int nID = Inst.Str2ID("op.contentItems.setProps", false); | ||
+ | PDFXEdit.IOperation Op = Inst.CreateOp(nID); | ||
+ | var input = Op.Params.Root["Input"]; | ||
+ | input.Add().v = Doc.CoreDoc; | ||
+ | PDFXEdit.ICabNode options = Op.Params.Root["Options"]; | ||
+ | int nSelID = Inst.Str2ID("selection.contentItems", false); | ||
+ | uint nPage = 0; //Page number that will have it's content items modified | ||
+ | //First we need to create content items selection | ||
+ | PDFXEdit.IPXV_ContentItemsSelection itSel = (PDFXEdit.IPXV_ContentItemsSelection)Doc.CreateStdSel((uint)nSelID); | ||
+ | //Then we need to get root item entry for the desired page (we'll create it if needed) | ||
+ | PDFXEdit.IPXV_ContentItemEntry itEntry = itSel.GetSel(nPage, true); | ||
+ | //Inserting needed content items from the page | ||
+ | var content = Doc.CoreDoc.Pages[nPage].GetContent(PDFXEdit.PXC_ContentAccessMode.CAccessMode_WeakClone); | ||
+ | for (uint i = 0; i < content.Items.Count; i++) | ||
+ | { | ||
+ | //For example we will take all of the text items | ||
+ | if (content.Items[i].Type == PDFXEdit.PXC_CIType.CIT_Text) | ||
+ | itEntry.Insert(i); | ||
+ | } | ||
+ | //Adding selected page's root entry with added content items to the operation | ||
+ | options["Entries"].Add(PDFXEdit.CabDataTypeID.dt_IUnknown).v = itEntry; | ||
+ | //Setting the color (note that rgb notation is rgb(r,g,b) where r g b are float values from 0.0 to 1.0) | ||
+ | options["FColor"].v = "#AC3312"; | ||
+ | //Setting mask that will tell the operation that the FColor will be modified | ||
+ | options["Mask"].v = 2; | ||
+ | Op.Do(); | ||
+ | //Clearing the selection | ||
+ | itSel.Clear(); | ||
+ | } | ||
+ | </pre> | ||
== See Also == | == See Also == | ||
− | [[PXV:IPXC_Page|IPXC_Page]] | + | [[PXV:IPXC_Page|IPXC_Page]] |
Latest revision as of 00:55, 22 April 2016
Gets content of the page with given access mode.
Syntax
HRESULT GetContent([in] PXC_ContentAccessMode nKMode, [out, retval] IPXC_Content** pContent);
Parameters
- nKMode
- [in] Access mode of the resulting content.
- pContent
- [out, retval] Pointer to IPXC_Content containing the resulting page content.
Return Value
Returns S_OK if operation was successful or error code in other cases.
Sample
//C# private void SetContentColor(PDFXEdit.IPXV_Document Doc, PDFXEdit.IPXV_Inst Inst) { if (Doc == null) return; //Creating contentItems.setProps operation int nID = Inst.Str2ID("op.contentItems.setProps", false); PDFXEdit.IOperation Op = Inst.CreateOp(nID); var input = Op.Params.Root["Input"]; input.Add().v = Doc.CoreDoc; PDFXEdit.ICabNode options = Op.Params.Root["Options"]; int nSelID = Inst.Str2ID("selection.contentItems", false); uint nPage = 0; //Page number that will have it's content items modified //First we need to create content items selection PDFXEdit.IPXV_ContentItemsSelection itSel = (PDFXEdit.IPXV_ContentItemsSelection)Doc.CreateStdSel((uint)nSelID); //Then we need to get root item entry for the desired page (we'll create it if needed) PDFXEdit.IPXV_ContentItemEntry itEntry = itSel.GetSel(nPage, true); //Inserting needed content items from the page var content = Doc.CoreDoc.Pages[nPage].GetContent(PDFXEdit.PXC_ContentAccessMode.CAccessMode_WeakClone); for (uint i = 0; i < content.Items.Count; i++) { //For example we will take all of the text items if (content.Items[i].Type == PDFXEdit.PXC_CIType.CIT_Text) itEntry.Insert(i); } //Adding selected page's root entry with added content items to the operation options["Entries"].Add(PDFXEdit.CabDataTypeID.dt_IUnknown).v = itEntry; //Setting the color (note that rgb notation is rgb(r,g,b) where r g b are float values from 0.0 to 1.0) options["FColor"].v = "#AC3312"; //Setting mask that will tell the operation that the FColor will be modified options["Mask"].v = 2; Op.Do(); //Clearing the selection itSel.Clear(); }