IPXC_Document::PlaceWatermark Method
From PDF XChange PDF SDK
m (Automatic page editing by robot) |
(→Sample) |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 3: | Line 3: | ||
{{#customTitle:IPXC_Document::PlaceWatermark Method}} | {{#customTitle:IPXC_Document::PlaceWatermark Method}} | ||
{{#parentPage:PXV:IPXC_Document#Methods|PlaceWatermark|method}} | {{#parentPage:PXV:IPXC_Document#Methods|PlaceWatermark|method}} | ||
− | |||
{{ToReview}} | {{ToReview}} | ||
− | + | Places watermarks with given parameters on pages specified with the [[PXV:IBitSet|PageIndexes]]. | |
== Syntax == | == Syntax == | ||
− | <pre class="brush:cpp;gutter:false">HRESULT PlaceWatermark([in] IBitSet* | + | <pre class="brush:cpp;gutter:false">HRESULT PlaceWatermark([in] IBitSet* pPageIndexes, |
− | [in] IPXC_WatermarkParams* | + | [in] IPXC_WatermarkParams* pParams, |
− | [in, defaultvalue(NULL)] IProgressMon* | + | [in, defaultvalue(NULL)] IProgressMon* pProgress);</pre> |
== Parameters == | == Parameters == | ||
− | ; | + | ;pPageIndexes |
− | :[in] Pointer to [[PXV:IBitSet|IBitSet]]. | + | :[in] Pointer to [[PXV:IBitSet|IBitSet]] containing the page indexes where the watermarks will be placed at. |
− | ; | + | ;pParams |
− | :[in] Pointer to [[PXV:IPXC_WatermarkParams|IPXC_WatermarkParams]]. | + | :[in] Pointer to [[PXV:IPXC_WatermarkParams|IPXC_WatermarkParams]] containing the new watermark parameters. |
− | ; | + | ;pProgress |
− | :[in, defaultvalue(NULL)] Pointer to [[PXV:IProgressMon|IProgressMon]]. | + | :[in, defaultvalue(NULL)] Pointer to [[PXV:IProgressMon|IProgressMon]] containing the custom progress implementation. |
== 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 PlaceWatermark(PDFXEdit.IPXC_Document Doc, PDFXEdit.IPXC_Inst Inst) | ||
+ | { | ||
+ | PDFXEdit.IAUX_Inst aInst = (PDFXEdit.IAUX_Inst)Inst.GetExtension("AUX"); | ||
+ | PDFXEdit.IBitSet bs = aInst.CreateBitSet(Doc.Pages.Count); | ||
+ | PDFXEdit.IPXC_WatermarkParams wp = Inst.CreateWatermarkParams(); | ||
+ | bs.Set(0, 4); //We will place watermarks on first 4 pages | ||
+ | wp.Text = "QWERTY"; | ||
+ | wp.FontSize = Convert.ToSingle(50); | ||
+ | Doc.PlaceWatermark(bs, wp); | ||
+ | } | ||
+ | |||
+ | private void PlaceImageWatermark(PDFXEdit.IPXC_Document Doc, PDFXEdit.IPXC_Inst Inst) | ||
+ | { | ||
+ | PDFXEdit.IAUX_Inst aInst = (PDFXEdit.IAUX_Inst)Inst.GetExtension("AUX"); | ||
+ | PDFXEdit.IBitSet bs = aInst.CreateBitSet(Doc.Pages.Count); | ||
+ | PDFXEdit.IPXC_WatermarkParams wp = Inst.CreateWatermarkParams(); | ||
+ | bs.Set(0, 4); //We will place watermarks on first 4 pages | ||
+ | wp.WatermarkType = PDFXEdit.PXC_WatermarkType.Watermark_PDF; | ||
+ | wp.ImageFile = @"D:\TestFile.pdf"; | ||
+ | wp.ImagePage = 0; | ||
+ | wp.Flags = (uint)PDFXEdit.PXC_WatermarkFlags.WatermarkFlag_ScaleToPage; | ||
+ | wp.Scale = 100; | ||
+ | wp.Opacity = 55; | ||
+ | Doc.PlaceWatermark(bs, wp); | ||
+ | } | ||
+ | </pre> | ||
== See Also == | == See Also == | ||
[[PXV:IPXC_Document|IPXC_Document]] | [[PXV:IPXC_Document|IPXC_Document]] |
Latest revision as of 23:13, 21 April 2016
Places watermarks with given parameters on pages specified with the PageIndexes.
Syntax
HRESULT PlaceWatermark([in] IBitSet* pPageIndexes, [in] IPXC_WatermarkParams* pParams, [in, defaultvalue(NULL)] IProgressMon* pProgress);
Parameters
- pPageIndexes
- [in] Pointer to IBitSet containing the page indexes where the watermarks will be placed at.
- pParams
- [in] Pointer to IPXC_WatermarkParams containing the new watermark parameters.
- pProgress
- [in, defaultvalue(NULL)] Pointer to IProgressMon containing the custom progress implementation.
Return Value
Returns S_OK if operation was successful or error code in other cases.
Sample
//C# private void PlaceWatermark(PDFXEdit.IPXC_Document Doc, PDFXEdit.IPXC_Inst Inst) { PDFXEdit.IAUX_Inst aInst = (PDFXEdit.IAUX_Inst)Inst.GetExtension("AUX"); PDFXEdit.IBitSet bs = aInst.CreateBitSet(Doc.Pages.Count); PDFXEdit.IPXC_WatermarkParams wp = Inst.CreateWatermarkParams(); bs.Set(0, 4); //We will place watermarks on first 4 pages wp.Text = "QWERTY"; wp.FontSize = Convert.ToSingle(50); Doc.PlaceWatermark(bs, wp); } private void PlaceImageWatermark(PDFXEdit.IPXC_Document Doc, PDFXEdit.IPXC_Inst Inst) { PDFXEdit.IAUX_Inst aInst = (PDFXEdit.IAUX_Inst)Inst.GetExtension("AUX"); PDFXEdit.IBitSet bs = aInst.CreateBitSet(Doc.Pages.Count); PDFXEdit.IPXC_WatermarkParams wp = Inst.CreateWatermarkParams(); bs.Set(0, 4); //We will place watermarks on first 4 pages wp.WatermarkType = PDFXEdit.PXC_WatermarkType.Watermark_PDF; wp.ImageFile = @"D:\TestFile.pdf"; wp.ImagePage = 0; wp.Flags = (uint)PDFXEdit.PXC_WatermarkFlags.WatermarkFlag_ScaleToPage; wp.Scale = 100; wp.Opacity = 55; Doc.PlaceWatermark(bs, wp); }