PDF Creator Pilot documentation |
Download CHM version of this manual. |
|
![]() ![]() Collapse AllThis method creates a watermark in a PDF document.
|
| LONG AddWatermark () |
Return value
Index of the new watermark
Remarks
The return value is a watermark identifier in the document's watermarks collection and can be used in SwitchToWatermark and AttachWatermark.
When you use Watermark functions, you must set the watermark to the page before all other output functions.
Example
How to insert an image and show it as a watermark in PDF
Delphi
[copy to clipboard]
{ PDF object is supposed to be created }
img := PDF.AddImageFromFile('watermark.jpg');
{ composing a watermark }
wtm := PDF.AddWatermark();
PDF.SwitchToWatermark(wtm);
PDF.ShowImage(img, 300, 500);
PDF.SetColorFill(0, 1, 0, 0);
PDF.ShowTextAt(330, 530, 'Watermark text');
PDF.SwitchToCurrentPage;
//composing 1st page
PDF.ShowTextAt(50, 50, 'Page1 with watermark.');
PDF.AttachWatermark(0, wtm);
//composing 2nd page
PDF.NewPage;
PDF.ShowTextAt(50, 50, 'Page2 with watermark.');
PDF.AttachWatermark(1, wtm);
//composing 3rd page
PDF.NewPage;
PDF.ShowTextAt(50, 50, 'Page3 with watermark.');
PDF.AttachWatermark(2, wtm);
PDF.SaveToFile('test.pdf', true);
C/C++
[copy to clipboard]
// PDF object is supposed to be created
long img = PDF->AddImageFromFile("watermark.jpg");
// composing a watermark
long wtm = PDF->AddWatermark();
PDF->SwitchToWatermark(wtm);
PDF->ShowImage(img, 300, 500);
PDF->SetColorFill(0f, 1f, 0f, 0f);
PDF->ShowTextAt(330, 530, "Watermark text");
PDF->SwitchToCurrentPage();
//composing 1st page
PDF->ShowTextAt(50, 50, "Page1 with watermark.");
PDF->AttachWatermark(0, wtm);
//composing 2nd page
PDF->NewPage();
PDF->ShowTextAt(50, 50, "Page2 with watermark.");
PDF->AttachWatermark(1, wtm);
//composing 3rd page
PDF->NewPage();
PDF->ShowTextAt(50, 50, "Page3 with watermark.");
PDF->AttachWatermark(2, wtm);
PDF->SaveToFile("test.pdf", true);
C#
[copy to clipboard]
// PDF object is supposed to be created
long img = PDF.AddImageFromFile("watermark.jpg");
// composing a watermark
long wtm = PDF.AddWatermark();
PDF.SwitchToWatermark(wtm);
PDF.ShowImage(img, 300, 500);
PDF.SetColorFill(0f, 1f, 0f, 0f);
PDF.ShowTextAt(330, 530, "Watermark text");
PDF.SwitchToCurrentPage();
//composing 1st page
PDF.ShowTextAt(50, 50, "Page1 with watermark.");
PDF.AttachWatermark(0, wtm);
//composing 2nd page
PDF.NewPage();
PDF.ShowTextAt(50, 50, "Page2 with watermark.");
PDF.AttachWatermark(1, wtm);
//composing 3rd page
PDF.NewPage();
PDF.ShowTextAt(50, 50, "Page3 with watermark.");
PDF.AttachWatermark(2, wtm);
PDF.SaveToFile("test.pdf", true);
Visual Basic
[copy to clipboard]
' PDF object is supposed to be created
img = PDF.AddImageFromFile("watermark.jpg")
' composing a watermark
wtm = PDF.AddWatermark
PDF.SwitchToWatermark wtm
PDF.ShowImage img, 300, 500
PDF.SetColorFill 0, 1, 0, 0
PDF.ShowTextAt 330, 530, "Watermark text"
PDF.SwitchToCurrentPage
'composing 1st page
PDF.ShowTextAt 50, 50, "Page1 with watermark."
PDF.AttachWatermark 0, wtm
'composing 2nd page
PDF.NewPage
PDF.AttachWatermark 1, wtm
PDF.ShowTextAt 50, 50, "Page2 with watermark."
'composing 3rd page
PDF.NewPage
PDF.AttachWatermark 2, wtm
PDF.ShowTextAt 50, 50, "Page3 with watermark."
PDF.SaveToFile "test.pdf", true
See Also
Reference


