Foxit PDF SDK
fs_watermark.h
Go to the documentation of this file.
1 
15 #ifndef FS_WATERMARK_H_
16 #define FS_WATERMARK_H_
17 
18 #include "common/fs_common.h"
19 #include "common/fs_image.h"
20 #include "pdf/fs_pdfdoc.h"
21 
27 namespace foxit {
31 namespace pdf {
32 // forward declaration
33 class WatermarkSettings;
34 class WatermarkTextProperties;
35 
40 class Watermark FS_FINAL : public Base {
41  public:
51  explicit Watermark(const PDFDoc& document, const wchar_t* text, const WatermarkTextProperties& properties,
52  const WatermarkSettings& settings);
53 
61  explicit Watermark(const foxit::pdf::PDFDoc& document, const foxit::common::Bitmap& bitmap, const foxit::pdf::WatermarkSettings& settings);
62 
75  explicit Watermark(const foxit::pdf::PDFDoc& document, const foxit::common::Image& image, int frame_index,
76  const foxit::pdf::WatermarkSettings& settings);
77 
85  explicit Watermark(const foxit::pdf::PDFDoc& document, const foxit::pdf::PDFPage& page, const foxit::pdf::WatermarkSettings& settings);
86 
92  Watermark(const Watermark& other);
100  Watermark& operator = (const Watermark& other);
101 
109  bool operator == (const Watermark& other) const;
117  bool operator != (const Watermark& other) const;
118 
120  ~Watermark();
121 
129  bool IsEmpty() const;
130 
138  float GetWidth() const;
139 
147  float GetHeight() const;
148 
164  bool InsertToPage(PDFPage page);
165 
166  // User is strongly recommended NOT to use this method; otherwise unknown situation may occur.
167  explicit Watermark(FS_HANDLE handle = NULL);
168 };
169 
171 class WatermarkSettings FS_FINAL : public Object {
172  public:
178  typedef enum _Flags {
182  e_FlagASAnnot = 0x0001,
184  e_FlagOnTop = 0x0002,
186  e_FlagNoPrint = 0x0004,
189  } Flags;
190 
191 
209  float scale_x, float scale_y, float rotation, int opacity)
210  : position(position)
211  , offset_x(offset_x)
212  , offset_y(offset_y)
213  , flags(flags)
214  , scale_x(scale_x)
215  , scale_y(scale_y)
216  , rotation(rotation)
217  , opacity(opacity) {}
218 
221  : position(CommonDefines::e_PosTopLeft)
222  , offset_x(0)
223  , offset_y(0)
224  , flags(0)
225  , scale_x(0)
226  , scale_y(0)
227  , rotation(0)
228  , opacity(100) {}
229 
236  : position(settings.position)
237  , offset_x(settings.offset_x)
238  , offset_y(settings.offset_y)
239  , flags(settings.flags)
240  , scale_x(settings.scale_x)
241  , scale_y(settings.scale_y)
242  , rotation(settings.rotation)
243  , opacity(settings.opacity) {}
244 
253  position = settings.position;
254  offset_x = settings.offset_x;
255  offset_y = settings.offset_y;
256  flags = settings.flags;
257  scale_x = settings.scale_x;
258  scale_y = settings.scale_y;
259  rotation = settings.rotation;
260  opacity = settings.opacity;
261  return *this;
262  }
263 
282  void Set(const common::Position position, float offset_x, float offset_y, uint32 flags, float scale_x, float scale_y,
283  float rotation, int opacity) {
284  this->position = position;
285  this->offset_x = offset_x;
286  this->offset_y = offset_y;
287  this->flags = flags;
288  this->scale_x = scale_x;
289  this->scale_y = scale_y;
290  this->rotation = rotation;
291  this->opacity = opacity;
292  }
293 
301  float offset_x;
303  float offset_y;
312  float scale_x;
314  float scale_y;
316  float rotation;
321  int opacity;
322 };
323 
325 class WatermarkTextProperties FS_FINAL : public Object {
326  public:
332  typedef enum _FontStyle {
337  } FontStyle;
338 
339 
363  : font(font)
365  , color(color)
366  , font_style(style)
368  , alignment(alignment) {}
369 
372  : font_size(0)
373  , color(0x000000)
375  , line_space(0)
376  , alignment(CommonDefines::e_AlignmentLeft) {}
377 
384  : font(properties.font)
385  , font_size(properties.font_size)
386  , color(properties.color)
387  , font_style(properties.font_style)
388  , line_space(properties.line_space)
389  , alignment(properties.alignment) {}
390 
399  font = properties.font;
400  font_size = properties.font_size;
401  color = properties.color;
402  font_style = properties.font_style;
403  line_space = properties.line_space;
404  alignment = properties.alignment;
405  return *this;
406  }
407 
432  void Set(const common::Font& font, float font_size, RGB color, FontStyle style, float line_space,
434  this->font = font;
435  this->font_size = font_size;
436  this->color = color;
437  this->font_style = style;
438  this->line_space = line_space;
439  this->alignment = alignment;
440  }
441 
445  float font_size;
464  float line_space;
475 };
476 } // namespace pdf
477 } // namespace foxit
478 #endif // FS_WATERMARK_H_
479 
Watermark & operator=(const Watermark &other)
Assign operator.
void Set(const common::Font &font, float font_size, RGB color, FontStyle style, float line_space, foxit::common ::Alignment alignment)
Set value.
Definition: fs_watermark.h:432
Definition: fs_image.h:36
If set, do not display a watermark.
Definition: fs_watermark.h:188
Position
Enumeration for watermark position in a PDF page.
Definition: fs_common.h:108
FontStyle
Enumeration for watermark font style.
Definition: fs_watermark.h:332
CFX_Object Object
Object type.
Definition: fs_basictypes.h:217
float font_size
Font size in points.
Definition: fs_watermark.h:445
float GetWidth() const
Get the original width of current watermark.
Watermark(const PDFDoc &document, const wchar_t *text, const WatermarkTextProperties &properties, const WatermarkSettings &settings)
Constructor, from specified text content.
Header file for PDF document related definitions and classes.
common::Position position
Watermark position.
Definition: fs_watermark.h:299
~Watermark()
Destructor.
uint32 RGB
RGB color type, 24 bits, ((b) | ((g) << 8) | ((r) << 16)))
Definition: fs_basictypes.h:212
foxit::common ::Alignment alignment
Text horizontal alignment.
Definition: fs_watermark.h:474
WatermarkSettings()
Constructor.
Definition: fs_watermark.h:220
Definition: fs_watermark.h:171
float offset_y
Vertical offset, in points.
Definition: fs_watermark.h:303
Watermark font style: with underline.
Definition: fs_watermark.h:336
Definition: fs_pdfdoc.h:389
If set, the watermark will be an annotation when inserted to a PDF page.
Definition: fs_watermark.h:182
Definition: fs_watermark.h:40
bool InsertToPage(PDFPage page)
Insert current watermark into a PDF page.
Header file for image and bitmap related definitions and classes.
Definition: fs_watermark.h:325
float offset_x
Horizontal offset, in points.
Definition: fs_watermark.h:301
bool operator !=(const Watermark &other) const
Not equal operator.
Watermark font style: normal.
Definition: fs_watermark.h:334
int opacity
Opacity in percents. Valid range: from 0 to 100. 0 for fully transparent and 100 for fully opaque.
Definition: fs_watermark.h:321
If set, show watermark above other page content.
Definition: fs_watermark.h:184
If set, the watermark will be a part of page content when inserted to a PDF page.
Definition: fs_watermark.h:180
WatermarkSettings & operator=(const WatermarkSettings &settings)
Assign operator.
Definition: fs_watermark.h:252
WatermarkTextProperties(const common::Font &font, float font_size, RGB color, FontStyle style, float line_space, foxit::common ::Alignment alignment)
Constructor, with parameters.
Definition: fs_watermark.h:361
float line_space
Space between vertical center of lines, in line heights.
Definition: fs_watermark.h:464
WatermarkTextProperties()
Constructor.
Definition: fs_watermark.h:371
If set, do not print a watermark.
Definition: fs_watermark.h:186
FontStyle font_style
Font style.
Definition: fs_watermark.h:456
FX_UINT32 uint32
32-bit unsigned integer.
Definition: fs_basictypes.h:196
Definition: fs_pdfpage.h:367
void * FS_HANDLE
Handle type.
Definition: fs_basictypes.h:214
Header file for common definitions and classes.
bool IsEmpty() const
Check whether current object is empty or not.
float scale_y
Vertical scale coefficient. It should be greater than 0.001f.
Definition: fs_watermark.h:314
Alignment
Enumeration for alignment (horizontal).
Definition: fs_common.h:74
WatermarkTextProperties(const WatermarkTextProperties &properties)
Constructor, with another watermark text properties object.
Definition: fs_watermark.h:383
Definition: fs_basictypes.h:397
WatermarkTextProperties & operator=(const WatermarkTextProperties &properties)
Assign operator.
Definition: fs_watermark.h:398
WatermarkSettings(const WatermarkSettings &settings)
Constructor, with another watermark settings object.
Definition: fs_watermark.h:235
Definition: fs_common.h:1146
Foxit namespace.
Definition: fs_compare.h:27
float GetHeight() const
Get the original height of current watermark.
Left alignment.
Definition: fs_common.h:76
common::Font font
A font object used for the text.
Definition: fs_watermark.h:443
float rotation
Rotation angle in degrees.
Definition: fs_watermark.h:316
uint32 flags
Watermark flags.
Definition: fs_watermark.h:310
WatermarkSettings(const common::Position position, float offset_x, float offset_y, uint32 flags, float scale_x, float scale_y, float rotation, int opacity)
Constructor, with parameters.
Definition: fs_watermark.h:208
#define NULL
The null-pointer value.
Definition: fx_system.h:767
Position: top left.
Definition: fs_common.h:110
float scale_x
Horizontal scale coefficient. It should be greater than 0.001f.
Definition: fs_watermark.h:312
Definition: fs_image.h:430
Flags
Enumeration for watermark setting flags.
Definition: fs_watermark.h:178
RGB color
Text color. Format: 0xRRGGBB.
Definition: fs_watermark.h:447
void Set(const common::Position position, float offset_x, float offset_y, uint32 flags, float scale_x, float scale_y, float rotation, int opacity)
Set value.
Definition: fs_watermark.h:282
bool operator==(const Watermark &other) const
Equal operator.