TextStamp.h
1 #pragma once
2 // Copyright (c) 2001-2024 Aspose Pty Ltd. All Rights Reserved.
3 
4 #include <system/array.h>
5 
6 #include "Aspose.PDF.Cpp/Text/TextOptions/TextFormattingOptions.h"
7 #include "Aspose.PDF.Cpp/Stamp.h"
8 #include "Aspose.PDF.Cpp/aspose_pdf_api_defs.h"
9 
10 namespace Aspose
11 {
12 namespace Pdf
13 {
14 namespace Engine
15 {
16 namespace Data
17 {
18 class IPdfDataStream;
19 class IPdfObject;
20 } // namespace Data
21 } // namespace Engine
22 namespace Facades
23 {
24 class FormattedText;
25 } // namespace Facades
26 enum class HorizontalAlignment;
27 class Page;
28 class Rectangle;
29 namespace Tests
30 {
31 namespace Facades
32 {
33 class FormattedTextTests;
34 } // namespace Facades
35 namespace Text
36 {
37 class TextBuilderTests;
38 } // namespace Text
39 } // namespace Tests
40 namespace Text
41 {
42 class Font;
43 class TextFragment;
44 class TextParagraph;
45 class TextState;
46 } // namespace Text
47 class TextStamp;
48 class XForm;
49 } // namespace Pdf
50 } // namespace Aspose
51 namespace System
52 {
53 namespace Collections
54 {
55 namespace Generic
56 {
57 template <typename> class List;
58 } // namespace Generic
59 } // namespace Collections
60 } // namespace System
61 
62 namespace Aspose {
63 
64 namespace Pdf {
65 
69 class ASPOSE_PDF_SHARED_CLASS TextStamp : public Aspose::Pdf::Stamp
70 {
71  typedef TextStamp ThisType;
73 
74  typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
75  ASPOSE_PDF_SHARED_RTTI_INFO_DECL();
76 
80  friend class Aspose::Pdf::Tests::Text::TextBuilderTests;
81  friend class Aspose::Pdf::Tests::Facades::FormattedTextTests;
82 
83 public:
84 
88  enum class NoCharacterAction
89  {
93  ThrowException,
97  UseStandardFont,
101  ReplaceAnyway,
105  UseCustomReplacementFont
106  };
107 
108 
109 private:
110 
111  class TextLine : public System::Object
112  {
113  typedef TextLine ThisType;
114  typedef System::Object BaseType;
115 
116  typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
117  RTTI_INFO_DECL();
118 
119  public:
120 
121  System::String get_Text() const;
122  double get_Spacing() const;
123 
124  TextLine(System::String text, double spacing);
125  TextLine(System::String text);
126 
127  private:
128 
129  System::String _text;
130  double _spacing;
131 
132  };
133 
134  class WordInfo : public System::Object
135  {
136  typedef WordInfo ThisType;
137  typedef System::Object BaseType;
138 
139  typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
140  RTTI_INFO_DECL();
141 
142  public:
143 
144  System::String text;
145  System::String space;
146 
147  System::String get_SpecialFont() const;
148  void set_SpecialFont(System::String value);
149 
150  WordInfo(System::String text);
151  WordInfo();
152 
153  private:
154 
155  System::String pr_SpecialFont;
156 
157  };
158 
159 
160 public:
161 
165  ASPOSE_PDF_SHARED_API bool get_Draw() const;
169  ASPOSE_PDF_SHARED_API void set_Draw(bool value);
175  ASPOSE_PDF_SHARED_API bool get_TreatYIndentAsBaseLine() const;
181  ASPOSE_PDF_SHARED_API void set_TreatYIndentAsBaseLine(bool value);
186  ASPOSE_PDF_SHARED_API bool get_WordWrap() const;
191  ASPOSE_PDF_SHARED_API void set_WordWrap(bool value);
195  ASPOSE_PDF_SHARED_API Aspose::Pdf::Text::TextFormattingOptions::WordWrapMode get_WordWrapMode() const;
199  ASPOSE_PDF_SHARED_API void set_WordWrapMode(Aspose::Pdf::Text::TextFormattingOptions::WordWrapMode value);
203  ASPOSE_PDF_SHARED_API bool get_Justify();
207  ASPOSE_PDF_SHARED_API void set_Justify(bool value);
211  ASPOSE_PDF_SHARED_API bool get_Scale() const;
215  ASPOSE_PDF_SHARED_API void set_Scale(bool value);
219  ASPOSE_PDF_SHARED_API System::String get_Value();
223  ASPOSE_PDF_SHARED_API void set_Value(System::String value);
227  ASPOSE_PDF_SHARED_API System::SharedPtr<Aspose::Pdf::Text::TextState> get_TextState() const;
231  ASPOSE_PDF_SHARED_API Aspose::Pdf::HorizontalAlignment get_TextAlignment() const;
235  ASPOSE_PDF_SHARED_API void set_TextAlignment(Aspose::Pdf::HorizontalAlignment value);
239  ASPOSE_PDF_SHARED_API System::SharedPtr<Text::Font> get_ReplacementFont() const;
243  ASPOSE_PDF_SHARED_API void set_ReplacementFont(System::SharedPtr<Text::Font> value);
247  ASPOSE_PDF_SHARED_API TextStamp::NoCharacterAction get_NoCharacterBehavior() const;
251  ASPOSE_PDF_SHARED_API void set_NoCharacterBehavior(TextStamp::NoCharacterAction value);
255  ASPOSE_PDF_SHARED_API double get_Width() override;
259  ASPOSE_PDF_SHARED_API void set_Width(double value) override;
263  ASPOSE_PDF_SHARED_API double get_Height() override;
267  ASPOSE_PDF_SHARED_API void set_Height(double value) override;
271  ASPOSE_PDF_SHARED_API double get_MaxRowWidth() const;
275  ASPOSE_PDF_SHARED_API void set_MaxRowWidth(double value);
276 
283  ASPOSE_PDF_SHARED_API TextStamp(System::String value);
289  ASPOSE_PDF_SHARED_API TextStamp(System::String value, System::SharedPtr<Aspose::Pdf::Text::TextState> textState);
290 
297  ASPOSE_PDF_SHARED_API void Put(System::SharedPtr<Page> page) override;
298 
303  ASPOSE_PDF_SHARED_API TextStamp(System::SharedPtr<Facades::FormattedText> formattedText);
304 
305 protected:
306 
311 
312  static System::SharedPtr<Aspose::Pdf::Text::Font> get_DefaultFont();
313 
314  static float DefaultFontSize;
315 
316  ASPOSE_PDF_SHARED_API void ClearCache() override;
321  ASPOSE_PDF_SHARED_API System::SharedPtr<Rectangle> getRect() override;
327  virtual ASPOSE_PDF_SHARED_API System::SharedPtr<XForm> createXForm(System::SharedPtr<Page> page);
328 
329 private:
330 
335  bool _wordwrap;
336  bool _scale;
337  bool _draw;
338  bool _useBaseLineOrigin;
339  bool _isOrigingSet;
340  double _desiredWidth;
341  double _desiredHeight;
343  TextStamp::NoCharacterAction noCharacterBehavior;
344  System::SharedPtr<Text::Font> replacementFont;
345  static double VERTICAL_INDENT;
347  double _maxRowWidth;
348 
349  bool IsBlankSpace(char16_t c);
353  int32_t FindSplitIndex(System::String word, int32_t startIndex, double maxWidth);
359 
360 };
361 
362 } // namespace Pdf
363 } // namespace Aspose
364 
365 
Class which represents formatted text. Contains information about text and its color, size, style.
Definition: FormattedText.h:65
String class used across the library. Is a substitute for C# System.String when translating code...
Definition: string.h:121
class ASPOSECPP_SHARED_CLASS List
Definition: ienumerable.h:17
An abstract class for various kinds of stamps which come as descendants.
Definition: Stamp.h:48
Base class that enables using methods available for System.Object class in C#. All non-trivial classe...
Definition: object.h:64
Definition: Artifact.h:71
Represents text paragraphs as multiline text object.
Definition: TextParagraph.h:86
HorizontalAlignment
Describes horizontal alignment.
Definition: HorizontalAlignment.h:16
Definition: signed_info.h:13
Aspose::Pdf::HorizontalAlignment _textAlignemnt
Alignment of the text.
Definition: TextStamp.h:310
Pointer class to wrap types being allocated on heap. Use it to manage memory for classes inheriting O...
Definition: SideBySidePdfComparer.h:24
Represents a text type.
WordWrapMode
Defines word wrapping strategies
Definition: TextFormattingOptions.h:48
Definition: AFRelationship.h:4
Represents textual stamp.
Definition: TextStamp.h:69
static float DefaultFontSize
Definition: TextStamp.h:314
NoCharacterAction
Action to perform if font does not contain required character.
Definition: TextStamp.h:88
List forward declaration.
Definition: Artifact.h:78
The coordinates are in the page coordinate context.
Represents a text state of a text
Definition: TextState.h:135
Whole PDF file will be submitted.