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:
180 typedef enum _Flags {
182 e_FlagASPageContents = 0x0000,
184 e_FlagASAnnot = 0x0001,
186 e_FlagOnTop = 0x0002,
188 e_FlagNoPrint = 0x0004,
190 e_FlagInvisible = 0x0008,
192 e_FlagShareImageStream = 0x0010,
194 e_FlagShareTextStream = 0x0020,
196 e_FlagSharePageStream = 0x0040
197 } Flags;
198
199
216 explicit WatermarkSettings(const common::Position position, float offset_x, float offset_y, uint32 flags,
217 float scale_x, float scale_y, float rotation, int opacity)
218 : position(position)
219 , offset_x(offset_x)
220 , offset_y(offset_y)
221 , flags(flags)
222 , scale_x(scale_x)
223 , scale_y(scale_y)
224 , rotation(rotation)
225 , opacity(opacity) {}
226
228 WatermarkSettings()
229 : position(CommonDefines::e_PosTopLeft)
230 , offset_x(0)
231 , offset_y(0)
232 , flags(0)
233 , scale_x(1.0)
234 , scale_y(1.0)
235 , rotation(0)
236 , opacity(100) {}
237
243 WatermarkSettings(const WatermarkSettings& settings)
244 : position(settings.position)
245 , offset_x(settings.offset_x)
246 , offset_y(settings.offset_y)
247 , flags(settings.flags)
248 , scale_x(settings.scale_x)
249 , scale_y(settings.scale_y)
250 , rotation(settings.rotation)
251 , opacity(settings.opacity) {}
252
260 WatermarkSettings& operator = (const WatermarkSettings& settings) {
261 position = settings.position;
262 offset_x = settings.offset_x;
263 offset_y = settings.offset_y;
264 flags = settings.flags;
265 scale_x = settings.scale_x;
266 scale_y = settings.scale_y;
267 rotation = settings.rotation;
268 opacity = settings.opacity;
269 return *this;
270 }
271
290 void Set(const common::Position position, float offset_x, float offset_y, uint32 flags, float scale_x, float scale_y,
291 float rotation, int opacity) {
292 this->position = position;
293 this->offset_x = offset_x;
294 this->offset_y = offset_y;
295 this->flags = flags;
296 this->scale_x = scale_x;
297 this->scale_y = scale_y;
298 this->rotation = rotation;
299 this->opacity = opacity;
300 }
301
307 common::Position position;
309 float offset_x;
311 float offset_y;
318 uint32 flags;
320 float scale_x;
322 float scale_y;
324 float rotation;
329 int opacity;
330 };
331
333 class WatermarkTextProperties FS_FINAL : public Object {
334 public:
340 typedef enum _FontStyle {
342 e_FontStyleNormal = 0,
344 e_FontStyleUnderline = 1
345 } FontStyle;
346
347
371 WatermarkTextProperties(const common::Font& font, float font_size, RGB color, FontStyle style, float line_space,
372 CommonDefines::Alignment alignment)
373 : font(font)
374 , font_size(font_size)
375 , color(color)
376 , font_style(style)
377 , line_space(line_space)
378 , alignment(alignment) {}
379
381 WatermarkTextProperties()
382 : font_size(24.0)
383 , color(0x000000)
384 , font_style(e_FontStyleNormal)
385 , line_space(1.0)
386 , alignment(CommonDefines::e_AlignmentLeft) {}
387
393 WatermarkTextProperties(const WatermarkTextProperties& properties)
394 : font(properties.font)
395 , font_size(properties.font_size)
396 , color(properties.color)
397 , font_style(properties.font_style)
398 , line_space(properties.line_space)
399 , alignment(properties.alignment) {}
400
408 WatermarkTextProperties& operator = (const WatermarkTextProperties& properties) {
409 font = properties.font;
410 font_size = properties.font_size;
411 color = properties.color;
412 font_style = properties.font_style;
413 line_space = properties.line_space;
414 alignment = properties.alignment;
415 return *this;
416 }
417
444 void Set(const common::Font& font, float font_size, RGB color, FontStyle style, float line_space,
445 CommonDefines::Alignment alignment) {
446 this->font = font;
447 this->font_size = font_size;
448 this->color = color;
449 this->font_style = style;
450 this->line_space = line_space;
451 this->alignment = alignment;
452 }
453
455 common::Font font;
457 float font_size;
459 RGB color;
468 FontStyle font_style;
476 float line_space;
486 CommonDefines::Alignment alignment;
487 };
488 } // namespace pdf
489 } // namespace foxit
490 #endif // FS_WATERMARK_H_
491
foxit::pdf::WatermarkSettings::WatermarkSettings
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:216
foxit::FS_HANDLE
void * FS_HANDLE
Handle type.
Definition: fs_basictypes.h:213
foxit::pdf::Watermark::GetHeight
float GetHeight() const
Get the original height of current watermark.
foxit::pdf::WatermarkSettings::Set
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:290
foxit::pdf::WatermarkSettings::e_FlagSharePageStream
If set, watermarks will share one form xobject if these watermarks use the same page object.
Definition: fs_watermark.h:196
foxit::common::Position
Position
Enumeration for watermark position in a PDF page.
Definition: fs_common.h:128
foxit::pdf::Watermark::operator==
bool operator==(const Watermark &other) const
Equal operator.
foxit::pdf::Watermark::operator!=
bool operator!=(const Watermark &other) const
Not equal operator.
foxit::Object
CFX_Object Object
Object type.
Definition: fs_basictypes.h:220
foxit::pdf::WatermarkTextProperties::color
RGB color
Text color. Format: 0xRRGGBB. The default value is 0x000000.
Definition: fs_watermark.h:459
foxit::pdf::WatermarkSettings::e_FlagInvisible
If set, do not display a watermark.
Definition: fs_watermark.h:190
foxit::pdf::WatermarkSettings
Definition: fs_watermark.h:172
foxit::pdf::WatermarkTextProperties::Set
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:444
fs_common.h
Header file for common definitions and classes.
foxit::pdf::WatermarkSettings::e_FlagShareTextStream
If set, watermarks will share one form xobject if these watermarks use the same text and text's relat...
Definition: fs_watermark.h:194
foxit::pdf::WatermarkSettings::WatermarkSettings
WatermarkSettings()
Constructor.
Definition: fs_watermark.h:228
foxit::common::Alignment
Alignment
Enumeration for alignment (horizontal).
Definition: fs_common.h:94
foxit::pdf::WatermarkTextProperties::FontStyle
FontStyle
Enumeration for watermark font style.
Definition: fs_watermark.h:340
foxit::pdf::WatermarkSettings::position
common::Position position
Watermark position.
Definition: fs_watermark.h:307
foxit::pdf::WatermarkTextProperties
Definition: fs_watermark.h:333
foxit::pdf::Watermark::IsEmpty
bool IsEmpty() const
Check whether current object is empty or not.
foxit::common::e_AlignmentLeft
Left alignment.
Definition: fs_common.h:96
foxit::pdf::WatermarkSettings::opacity
int opacity
Opacity in percents. Valid range: from 0 to 100. 0 for fully transparent and 100 for fully opaque.
Definition: fs_watermark.h:329
foxit::pdf::WatermarkSettings::offset_y
float offset_y
Vertical offset, in points.
Definition: fs_watermark.h:311
foxit::pdf::WatermarkTextProperties::line_space
float line_space
Space between vertical center of lines, in line heights. The default value is 1.0.
Definition: fs_watermark.h:476
foxit::pdf::WatermarkSettings::e_FlagNoPrint
If set, do not print a watermark.
Definition: fs_watermark.h:188
foxit::pdf::WatermarkSettings::offset_x
float offset_x
Horizontal offset, in points.
Definition: fs_watermark.h:309
foxit::common::e_PosTopLeft
Position: top left.
Definition: fs_common.h:130
foxit::pdf::WatermarkTextProperties::alignment
foxit::common ::Alignment alignment
Text horizontal alignment. The default value is common::e_AlignmentLeft.
Definition: fs_watermark.h:486
foxit::pdf::WatermarkSettings::e_FlagShareImageStream
If set, watermarks will share one image stream if these watermarks use the same image or bitmap.
Definition: fs_watermark.h:192
foxit::pdf::Watermark::GetWidth
float GetWidth() const
Get the original width of current watermark.
foxit::pdf::WatermarkTextProperties::font_style
FontStyle font_style
Font style.The default value is WatermarkTextProperties::e_FontStyleNormal.
Definition: fs_watermark.h:468
foxit::pdf::WatermarkSettings::e_FlagASPageContents
If set, the watermark will be a part of page content when inserted to a PDF page.
Definition: fs_watermark.h:182
foxit::pdf::Watermark::InsertToPage
bool InsertToPage(PDFPage page)
Insert current watermark into a PDF page.
foxit::pdf::Watermark::Watermark
Watermark(const PDFDoc &document, const wchar_t *text, const WatermarkTextProperties &properties, const WatermarkSettings &settings)
Constructor, from specified text content.
foxit::pdf::WatermarkSettings::e_FlagASAnnot
If set, the watermark will be an annotation when inserted to a PDF page.
Definition: fs_watermark.h:184
foxit::pdf::WatermarkTextProperties::operator=
WatermarkTextProperties & operator=(const WatermarkTextProperties &properties)
Assign operator.
Definition: fs_watermark.h:408
foxit::pdf::WatermarkSettings::WatermarkSettings
WatermarkSettings(const WatermarkSettings &settings)
Constructor, with another watermark settings object.
Definition: fs_watermark.h:243
foxit::pdf::WatermarkTextProperties::font
common::Font font
A font object used for the text.
Definition: fs_watermark.h:455
foxit
Foxit namespace.
Definition: fs_taggedpdf.h:27
foxit::pdf::WatermarkTextProperties::e_FontStyleUnderline
Watermark font style: with underline.
Definition: fs_watermark.h:344
foxit::pdf::WatermarkSettings::operator=
WatermarkSettings & operator=(const WatermarkSettings &settings)
Assign operator.
Definition: fs_watermark.h:260
foxit::pdf::WatermarkSettings::e_FlagOnTop
If set, show watermark above other page content.
Definition: fs_watermark.h:186
foxit::pdf::Watermark::operator=
Watermark & operator=(const Watermark &other)
Assign operator.
fs_image.h
Header file for image and bitmap related definitions and classes.
foxit::pdf::Watermark
Definition: fs_watermark.h:40
fs_pdfdoc.h
Header file for PDF document related definitions and classes.
foxit::pdf::WatermarkTextProperties::e_FontStyleNormal
Watermark font style: normal.
Definition: fs_watermark.h:342
foxit::pdf::WatermarkSettings::scale_y
float scale_y
Vertical scale coefficient. It should be greater than 0.001f.
Definition: fs_watermark.h:322
foxit::pdf::WatermarkTextProperties::WatermarkTextProperties
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:371
NULL
#define NULL
The null-pointer value.
Definition: fx_system.h:792
foxit::RGB
uint32 RGB
RGB color type, 24 bits, ((b) | ((g) << 8) | ((r) << 16)))
Definition: fs_basictypes.h:211
foxit::pdf::PDFDoc
Definition: fs_pdfdoc.h:776
foxit::pdf::WatermarkTextProperties::WatermarkTextProperties
WatermarkTextProperties()
Constructor.
Definition: fs_watermark.h:381
foxit::pdf::PDFPage
Definition: fs_pdfpage.h:412
foxit::pdf::Watermark::~Watermark
~Watermark()
Destructor.
foxit::common::Image
Definition: fs_image.h:459
foxit::common::Font
Definition: fs_common.h:1523
foxit::pdf::WatermarkSettings::rotation
float rotation
Rotation angle in degrees.
Definition: fs_watermark.h:324
foxit::pdf::WatermarkTextProperties::WatermarkTextProperties
WatermarkTextProperties(const WatermarkTextProperties &properties)
Constructor, with another watermark text properties object.
Definition: fs_watermark.h:393
foxit::pdf::WatermarkSettings::flags
uint32 flags
Watermark flags.
Definition: fs_watermark.h:318
foxit::common::Bitmap
Definition: fs_image.h:36
foxit::pdf::WatermarkTextProperties::font_size
float font_size
Font size in points. The default value is 24.0.
Definition: fs_watermark.h:457
foxit::uint32
FX_UINT32 uint32
32-bit unsigned integer.
Definition: fs_basictypes.h:195
foxit::Base
Definition: fs_basictypes.h:451
foxit::pdf::WatermarkSettings::scale_x
float scale_x
Horizontal scale coefficient. It should be greater than 0.001f.
Definition: fs_watermark.h:320
foxit::pdf::WatermarkSettings::Flags
Flags
Enumeration for watermark setting flags.
Definition: fs_watermark.h:180