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);
93 
101  Watermark& operator = (const Watermark& other);
102 
110  bool operator == (const Watermark& other) const;
118  bool operator != (const Watermark& other) const;
119 
121  ~Watermark();
122 
130  bool IsEmpty() const;
131 
139  float GetWidth() const;
140 
148  float GetHeight() const;
149 
165  bool InsertToPage(PDFPage page);
166 
167  // User is strongly recommended NOT to use this method; otherwise unknown situation may occur.
168  explicit Watermark(FS_HANDLE handle = NULL);
169 };
170 
172 class WatermarkSettings FS_FINAL : public Object {
173  public:
179  typedef enum _Flags {
183  e_FlagASAnnot = 0x0001,
185  e_FlagOnTop = 0x0002,
187  e_FlagNoPrint = 0x0004,
189  e_FlagInvisible = 0x0008,
192  } Flags;
193 
194 
212  float scale_x, float scale_y, float rotation, int opacity)
213  : position(position)
214  , offset_x(offset_x)
215  , offset_y(offset_y)
216  , flags(flags)
217  , scale_x(scale_x)
218  , scale_y(scale_y)
219  , rotation(rotation)
220  , opacity(opacity) {}
221 
224  : position(CommonDefines::e_PosTopLeft)
225  , offset_x(0)
226  , offset_y(0)
227  , flags(0)
228  , scale_x(0)
229  , scale_y(0)
230  , rotation(0)
231  , opacity(100) {}
232 
239  : position(settings.position)
240  , offset_x(settings.offset_x)
241  , offset_y(settings.offset_y)
242  , flags(settings.flags)
243  , scale_x(settings.scale_x)
244  , scale_y(settings.scale_y)
245  , rotation(settings.rotation)
246  , opacity(settings.opacity) {}
247 
256  position = settings.position;
257  offset_x = settings.offset_x;
258  offset_y = settings.offset_y;
259  flags = settings.flags;
260  scale_x = settings.scale_x;
261  scale_y = settings.scale_y;
262  rotation = settings.rotation;
263  opacity = settings.opacity;
264  return *this;
265  }
266 
285  void Set(const common::Position position, float offset_x, float offset_y, uint32 flags, float scale_x, float scale_y,
286  float rotation, int opacity) {
287  this->position = position;
288  this->offset_x = offset_x;
289  this->offset_y = offset_y;
290  this->flags = flags;
291  this->scale_x = scale_x;
292  this->scale_y = scale_y;
293  this->rotation = rotation;
294  this->opacity = opacity;
295  }
296 
304  float offset_x;
306  float offset_y;
315  float scale_x;
317  float scale_y;
319  float rotation;
324  int opacity;
325 };
326 
328 class WatermarkTextProperties FS_FINAL : public Object {
329  public:
335  typedef enum _FontStyle {
340  } FontStyle;
341 
342 
366  : font(font)
368  , color(color)
369  , font_style(style)
371  , alignment(alignment) {}
372 
375  : font_size(0)
376  , color(0x000000)
378  , line_space(0)
379  , alignment(CommonDefines::e_AlignmentLeft) {}
380 
387  : font(properties.font)
388  , font_size(properties.font_size)
389  , color(properties.color)
390  , font_style(properties.font_style)
391  , line_space(properties.line_space)
392  , alignment(properties.alignment) {}
393 
402  font = properties.font;
403  font_size = properties.font_size;
404  color = properties.color;
405  font_style = properties.font_style;
406  line_space = properties.line_space;
407  alignment = properties.alignment;
408  return *this;
409  }
410 
435  void Set(const common::Font& font, float font_size, RGB color, FontStyle style, float line_space,
437  this->font = font;
438  this->font_size = font_size;
439  this->color = color;
440  this->font_style = style;
441  this->line_space = line_space;
442  this->alignment = alignment;
443  }
444 
448  float font_size;
467  float line_space;
478 };
479 } // namespace pdf
480 } // namespace foxit
481 #endif // FS_WATERMARK_H_
482 
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:435
Definition: fs_image.h:36
If set, do not display a watermark.
Definition: fs_watermark.h:189
Position
Enumeration for watermark position in a PDF page.
Definition: fs_common.h:109
FontStyle
Enumeration for watermark font style.
Definition: fs_watermark.h:335
CFX_Object Object
Object type.
Definition: fs_basictypes.h:217
float font_size
Font size in points.
Definition: fs_watermark.h:448
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:302
~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:477
WatermarkSettings()
Constructor.
Definition: fs_watermark.h:223
If set, watermarks will share one image stream if these watermarks use the same image or bitmap.
Definition: fs_watermark.h:191
Definition: fs_watermark.h:172
float offset_y
Vertical offset, in points.
Definition: fs_watermark.h:306
Watermark font style: with underline.
Definition: fs_watermark.h:339
Definition: fs_pdfdoc.h:508
If set, the watermark will be an annotation when inserted to a PDF page.
Definition: fs_watermark.h:183
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:328
float offset_x
Horizontal offset, in points.
Definition: fs_watermark.h:304
bool operator !=(const Watermark &other) const
Not equal operator.
Watermark font style: normal.
Definition: fs_watermark.h:337
int opacity
Opacity in percents. Valid range: from 0 to 100. 0 for fully transparent and 100 for fully opaque.
Definition: fs_watermark.h:324
If set, show watermark above other page content.
Definition: fs_watermark.h:185
If set, the watermark will be a part of page content when inserted to a PDF page.
Definition: fs_watermark.h:181
WatermarkSettings & operator=(const WatermarkSettings &settings)
Assign operator.
Definition: fs_watermark.h:255
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:364
float line_space
Space between vertical center of lines, in line heights.
Definition: fs_watermark.h:467
WatermarkTextProperties()
Constructor.
Definition: fs_watermark.h:374
If set, do not print a watermark.
Definition: fs_watermark.h:187
FontStyle font_style
Font style.
Definition: fs_watermark.h:459
FX_UINT32 uint32
32-bit unsigned integer.
Definition: fs_basictypes.h:196
Definition: fs_pdfpage.h:411
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:317
Alignment
Enumeration for alignment (horizontal).
Definition: fs_common.h:75
WatermarkTextProperties(const WatermarkTextProperties &properties)
Constructor, with another watermark text properties object.
Definition: fs_watermark.h:386
Definition: fs_basictypes.h:407
WatermarkTextProperties & operator=(const WatermarkTextProperties &properties)
Assign operator.
Definition: fs_watermark.h:401
WatermarkSettings(const WatermarkSettings &settings)
Constructor, with another watermark settings object.
Definition: fs_watermark.h:238
Definition: fs_common.h:1334
Foxit namespace.
Definition: fs_taggedpdf.h:27
float GetHeight() const
Get the original height of current watermark.
Left alignment.
Definition: fs_common.h:77
common::Font font
A font object used for the text.
Definition: fs_watermark.h:446
float rotation
Rotation angle in degrees.
Definition: fs_watermark.h:319
uint32 flags
Watermark flags.
Definition: fs_watermark.h:313
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:211
#define NULL
The null-pointer value.
Definition: fx_system.h:780
Position: top left.
Definition: fs_common.h:111
float scale_x
Horizontal scale coefficient. It should be greater than 0.001f.
Definition: fs_watermark.h:315
Definition: fs_image.h:445
Flags
Enumeration for watermark setting flags.
Definition: fs_watermark.h:179
RGB color
Text color. Format: 0xRRGGBB.
Definition: fs_watermark.h:450
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:285
bool operator==(const Watermark &other) const
Equal operator.