IPXC_Document::PlaceWatermark Method
From PDF XChange PDF SDK
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); }