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
01 | //C# |
02 | private void PlaceWatermark(PDFXEdit.IPXC_Document Doc, PDFXEdit.IPXC_Inst Inst) |
03 | { |
04 | PDFXEdit.IAUX_Inst aInst = (PDFXEdit.IAUX_Inst)Inst.GetExtension( "AUX" ); |
05 | PDFXEdit.IBitSet bs = aInst.CreateBitSet(Doc.Pages.Count); |
06 | PDFXEdit.IPXC_WatermarkParams wp = Inst.CreateWatermarkParams(); |
07 | bs.Set(0, 4); //We will place watermarks on first 4 pages |
08 | wp.Text = "QWERTY" ; |
09 | wp.FontSize = Convert.ToSingle(50); |
10 | Doc.PlaceWatermark(bs, wp); |
11 | } |
12 |
13 | private void PlaceImageWatermark(PDFXEdit.IPXC_Document Doc, PDFXEdit.IPXC_Inst Inst) |
14 | { |
15 | PDFXEdit.IAUX_Inst aInst = (PDFXEdit.IAUX_Inst)Inst.GetExtension( "AUX" ); |
16 | PDFXEdit.IBitSet bs = aInst.CreateBitSet(Doc.Pages.Count); |
17 | PDFXEdit.IPXC_WatermarkParams wp = Inst.CreateWatermarkParams(); |
18 | bs.Set(0, 4); //We will place watermarks on first 4 pages |
19 | wp.WatermarkType = PDFXEdit.PXC_WatermarkType.Watermark_PDF; |
20 | wp.ImageFile = @"D:\TestFile.pdf" ; |
21 | wp.ImagePage = 0; |
22 | wp.Flags = ( uint )PDFXEdit.PXC_WatermarkFlags.WatermarkFlag_ScaleToPage; |
23 | wp.Scale = 100; |
24 | wp.Opacity = 55; |
25 | Doc.PlaceWatermark(bs, wp); |
26 | } |