TextBoxField.h
1 #pragma once
2 // Copyright (c) 2001-2024 Aspose Pty Ltd. All Rights Reserved.
3 
4 #include <system/string.h>
5 
6 #include "Aspose.PDF.Cpp/InteractiveFeatures/Forms/Field.h"
7 #include "Aspose.PDF.Cpp/InteractiveFeatures/Annotations/Annotation.h"
8 #include "Aspose.PDF.Cpp/aspose_pdf_api_defs.h"
9 
10 namespace Aspose
11 {
12 namespace Pdf
13 {
14 class Document;
15 namespace Engine
16 {
17 namespace CommonData
18 {
19 namespace Text
20 {
21 namespace Fonts
22 {
23 class IPdfFont;
24 } // namespace Fonts
25 } // namespace Text
26 } // namespace CommonData
27 namespace Data
28 {
29 class IPdfObject;
30 class ITrailerable;
31 } // namespace Data
32 } // namespace Engine
33 namespace Facades
34 {
35 class FormEditor;
36 } // namespace Facades
37 namespace Forms
38 {
39 class BarcodeField;
40 class ComboBoxField;
41 class FileSelectBoxField;
42 class PasswordBoxField;
43 class RichTextBoxField;
44 } // namespace Forms
45 class Operator;
46 class OperatorCollection;
47 class Page;
48 class Rectangle;
49 namespace Tests
50 {
51 namespace Facades
52 {
53 class DomFormTests;
54 } // namespace Facades
55 } // namespace Tests
56 class TextBoxFieldXfa;
57 enum class VerticalAlignment;
58 } // namespace Pdf
59 } // namespace Aspose
60 namespace System
61 {
62 namespace Collections
63 {
64 namespace Generic
65 {
66 template <typename> class List;
67 } // namespace Generic
68 } // namespace Collections
69 namespace Drawing
70 {
71 class Image;
72 } // namespace Drawing
73 namespace Text
74 {
75 class StringBuilder;
76 } // namespace Text
77 } // namespace System
78 
79 namespace Aspose {
80 
81 namespace Pdf {
82 
83 namespace Forms {
84 
88 class ASPOSE_PDF_SHARED_CLASS TextBoxField : public Aspose::Pdf::Forms::Field
89 {
90  typedef TextBoxField ThisType;
92 
93  typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
94  ASPOSE_PDF_SHARED_RTTI_INFO_DECL();
95 
103  friend class Aspose::Pdf::TextBoxFieldXfa;
104  friend class Aspose::Pdf::Tests::Facades::DomFormTests;
105 
106 public:
107 
111  ASPOSE_PDF_SHARED_API bool get_Multiline();
115  ASPOSE_PDF_SHARED_API void set_Multiline(bool value);
119  ASPOSE_PDF_SHARED_API bool get_SpellCheck();
123  ASPOSE_PDF_SHARED_API void set_SpellCheck(bool value);
127  ASPOSE_PDF_SHARED_API bool get_Scrollable();
131  ASPOSE_PDF_SHARED_API void set_Scrollable(bool value);
135  ASPOSE_PDF_SHARED_API bool get_ForceCombs();
139  ASPOSE_PDF_SHARED_API void set_ForceCombs(bool value);
143  ASPOSE_PDF_SHARED_API int32_t get_MaxLen();
147  ASPOSE_PDF_SHARED_API void set_MaxLen(int32_t value);
151  ASPOSE_PDF_SHARED_API Aspose::Pdf::VerticalAlignment get_TextVerticalAlignment() const;
155  ASPOSE_PDF_SHARED_API void set_TextVerticalAlignment(Aspose::Pdf::VerticalAlignment value);
159  ASPOSE_PDF_SHARED_API System::String get_Value() override;
163  ASPOSE_PDF_SHARED_API void set_Value(System::String value) override;
164 
169  ASPOSE_PDF_SHARED_API TextBoxField(System::SharedPtr<Document> doc);
173  ASPOSE_PDF_SHARED_API TextBoxField();
186 
193  ASPOSE_PDF_SHARED_API void AddImage(System::SharedPtr<System::Drawing::Image> image);
201  ASPOSE_PDF_SHARED_API void AddBarcode(System::String code);
202 
203 protected:
204 
205  bool get_Justification() const;
206  void set_Justification(bool value);
207 
209 
210  MEMBER_FUNCTION_MAKE_OBJECT_DECLARATION(TextBoxField, CODEPORTING_ARGS(System::SharedPtr<Aspose::Pdf::Engine::Data::IPdfObject> annotation, System::SharedPtr<Document> document));
215  ASPOSE_PDF_SHARED_API void Initialize(System::SharedPtr<Aspose::Pdf::Engine::Data::ITrailerable> trailer) override;
216  ASPOSE_PDF_SHARED_API void Initialize(System::SharedPtr<Aspose::Pdf::Engine::Data::ITrailerable> trailer, System::SharedPtr<Rectangle> rect) override;
221  ASPOSE_PDF_SHARED_API bool AppearanceSupported() override;
229  static double GetDescent(System::SharedPtr<Aspose::Pdf::Engine::CommonData::Text::Fonts::IPdfFont> selectedFont, double fontSize);
230  static double GetAscent(System::SharedPtr<Aspose::Pdf::Engine::CommonData::Text::Fonts::IPdfFont> selectedFont, double fontSize);
231  virtual ASPOSE_PDF_SHARED_API double GetYOffset(double ty, double y, double lineHeight, double fontSize, double borderWidth, bool isMultiline);
232  virtual ASPOSE_PDF_SHARED_API float GetVerticalOffset(int32_t linesNumber, float height, double& lineHeight);
237  ASPOSE_PDF_SHARED_API void ClearAppearance(System::SharedPtr<OperatorCollection> appearance) override;
238  ASPOSE_PDF_SHARED_API System::SharedPtr<Field> CreateCopy() override;
239 
240  virtual ASPOSE_PDF_SHARED_API ~TextBoxField();
241 
242 private:
243 
244  int32_t maxLen;
245  System::String previousValue;
246  bool _justification;
247  static const double TtfExtraLineHeight;
248  static const double DefaultFontRatio;
249  static const double MaxFontRatio;
250  static const double FontSizeRatio;
251  static const double TextGap;
252  Aspose::Pdf::VerticalAlignment _verticalAlignment;
253 
262  double getTextWidth(System::String text, System::SharedPtr<Aspose::Pdf::Engine::CommonData::Text::Fonts::IPdfFont> font, double fontSize);
263  bool IsNewLine(System::String text, int32_t i);
264  bool IsWords(System::String text);
268  System::String ReduceCrlf(System::String text);
269  bool IsHieroglyphic(System::String s);
271  bool IsTextSplitted(System::String text);
272  double AdjustFontSize(System::String text, System::SharedPtr<Aspose::Pdf::Engine::CommonData::Text::Fonts::IPdfFont> font, double width, double height);
273  double CalculateFontSize(System::SharedPtr<Aspose::Pdf::Engine::CommonData::Text::Fonts::IPdfFont> font, System::String text, double rectWidth, double rectHeight);
274  double CalculateFontSize(System::String text, double rectHeight, double defaultFontSize);
276  void CheckOnFormatECMAScript(System::String value);
278  void ValidateBalance(System::SharedPtr<OperatorCollection> ops);
279 
280 };
281 
282 } // namespace Forms
283 } // namespace Pdf
284 } // namespace Aspose
285 
286 
VerticalAlignment
Enumeration of possible vertical alignment values.
Definition: VerticalAlignment.h:16
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
Class representing Combobox field of the form.
Definition: ComboBoxField.h:63
Definition: Artifact.h:71
Class represents barcode field.
Definition: BarcodeField.h:49
Class describes rich text editor component.
Definition: RichTextBoxField.h:64
Definition: signed_info.h:13
Base class for acro form fields.
Definition: Field.h:126
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.
Class representing text box field.
Definition: TextBoxField.h:88
Definition: AFRelationship.h:4
Defies a method that enables object cloning - creating a copy of an object. Objects of this class sho...
Definition: icloneable.h:15
List forward declaration.
Definition: Artifact.h:78
The coordinates are in the page coordinate context.
Represents a abstract base object can be added to the page(doc.Paragraphs.Add()). ...
Definition: BaseParagraph.h:66
Class descibes text field for entering password.
Definition: PasswordBoxField.h:35
Field for file select box element.
Definition: FileSelectBoxField.h:35
Class for editing forms (ading/deleting field etc)
Definition: FormEditor.h:73
Whole PDF file will be submitted.