Form.h
1 #pragma once
2 // Copyright (c) 2001-2024 Aspose Pty Ltd. All Rights Reserved.
3 
4 #include <system/collections/ienumerator.h>
5 #include <system/collections/icollection.h>
6 #include <system/array.h>
7 #include <cstdint>
8 
9 #include "Aspose.PDF.Cpp/aspose_pdf_api_defs.h"
10 
11 namespace Aspose
12 {
13 namespace Pal
14 {
15 class PalZipWriter;
16 } // namespace Pal
17 namespace Pdf
18 {
19 namespace Annotations
20 {
21 class DefaultAppearance;
22 namespace JavascriptExtensions
23 {
24 class ThisObjectExtension;
25 } // namespace JavascriptExtensions
26 class WidgetAnnotation;
27 class XfdfReader;
28 class XfdfWriter;
29 } // namespace Annotations
30 class ApsToPdfConverter;
31 enum class ApsToXpsSavingMode;
32 namespace Collections
33 {
34 template <typename, typename> class AsposeHashDictionary;
35 } // namespace Collections
36 class Copier;
37 class Document;
38 namespace Engine
39 {
40 namespace CommonData
41 {
42 namespace Text
43 {
44 namespace Fonts
45 {
46 namespace Utilities
47 {
48 class DocumentFontsIterator;
49 } // namespace Utilities
50 } // namespace Fonts
51 } // namespace Text
52 } // namespace CommonData
53 namespace Data
54 {
55 class IPdfArray;
56 class IPdfDictionary;
57 class IPdfPrimitive;
58 } // namespace Data
59 } // namespace Engine
60 namespace Facades
61 {
62 class Form;
63 class FormEditor;
64 class PdfConverter;
65 class PdfFileEditor;
66 class PdfFileSignature;
67 } // namespace Facades
68 namespace Forms
69 {
70 class Field;
71 enum class FormType;
72 class ListBoxField;
73 class XFA;
74 } // namespace Forms
75 namespace InteractiveFeatures
76 {
77 namespace Forms
78 {
79 class WidgetWrapper;
80 } // namespace Forms
81 } // namespace InteractiveFeatures
82 class PageCollection;
83 class PageGenerator;
84 class Rectangle;
85 class Resources;
86 namespace Tests
87 {
88 class InvalidFormTypeOperationExceptionTests;
89 class RegressionTests_v10_8;
90 class RegressionTests_v16_12;
91 class RegressionTests_v17_12;
92 class RegressionTests_v18_5;
93 class RegressionTests_v20_01;
94 class RegressionTests_v23_11;
95 class RegressionTests_v24_01;
96 class RegressionTests_v6_9;
97 class RegressionTests_v7_1;
98 class RegressionTests_v7_4;
99 class RegressionTests_v7_7;
100 class RegressionTests_v7_8;
101 class RegressionTests_v7_9;
102 class RegressionTests_v8_2;
103 class RegressionTests_v8_8;
104 class RegressionTests_v9_1;
105 class XfaRendererTests;
106 } // namespace Tests
107 namespace XfaConverter
108 {
109 class XfaParserOptions;
110 } // namespace XfaConverter
111 class XfaMerge;
112 enum class XfaTag;
113 class XfaToPdfConverter;
114 } // namespace Pdf
115 namespace XfaRenderer
116 {
117 namespace Core
118 {
119 class XfaFontCash;
120 } // namespace Core
121 } // namespace XfaRenderer
122 } // namespace Aspose
123 namespace System
124 {
125 namespace Collections
126 {
127 namespace Generic
128 {
129 template <typename, typename> class Dictionary;
130 template <typename> class HashSet;
131 template <typename> class IEnumerable;
132 template <typename> class List;
133 } // namespace Generic
134 } // namespace Collections
135 namespace IO
136 {
137 class MemoryStream;
138 class Stream;
139 } // namespace IO
140 class Uri;
141 namespace Xml
142 {
143 class XmlDocument;
144 class XmlNode;
145 } // namespace Xml
146 } // namespace System
147 
148 namespace Aspose {
149 
150 namespace Pdf {
151 
152 namespace Forms {
153 
157 class ASPOSE_PDF_SHARED_CLASS Form final : public System::Collections::Generic::ICollection<System::SharedPtr<Aspose::Pdf::Annotations::WidgetAnnotation>>
158 {
159  typedef Form ThisType;
161 
162  typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
163  ASPOSE_PDF_SHARED_RTTI_INFO_DECL();
164 
165  friend class Aspose::Pdf::ApsToPdfConverter;
166  friend class Aspose::Pdf::Engine::CommonData::Text::Fonts::Utilities::DocumentFontsIterator;
167  friend class Aspose::Pdf::PageGenerator;
168  friend class Aspose::Pdf::Document;
179  friend class Aspose::Pdf::Annotations::XfdfWriter;
182  friend class Aspose::Pdf::XfaToPdfConverter;
183  friend class Aspose::Pdf::XfaMerge;
184  friend class Aspose::Pdf::Annotations::JavascriptExtensions::ThisObjectExtension;
185  friend class Aspose::Pdf::Tests::XfaRendererTests;
186  friend class Aspose::Pdf::Tests::RegressionTests_v9_1;
187  friend class Aspose::Pdf::Tests::RegressionTests_v16_12;
188  friend class Aspose::Pdf::Tests::RegressionTests_v18_5;
189  friend class Aspose::Pdf::Tests::RegressionTests_v6_9;
190  friend class Aspose::Pdf::Tests::RegressionTests_v7_1;
191  friend class Aspose::Pdf::Tests::RegressionTests_v7_4;
192  friend class Aspose::Pdf::Tests::RegressionTests_v7_7;
193  friend class Aspose::Pdf::Tests::RegressionTests_v7_8;
194  friend class Aspose::Pdf::Tests::RegressionTests_v7_9;
195  friend class Aspose::Pdf::Tests::RegressionTests_v8_2;
196  friend class Aspose::Pdf::Tests::RegressionTests_v8_8;
197  friend class Aspose::Pdf::Tests::RegressionTests_v10_8;
198  friend class Aspose::Pdf::Tests::RegressionTests_v17_12;
199  friend class Aspose::Pdf::Tests::RegressionTests_v20_01;
200  friend class Aspose::Pdf::Tests::RegressionTests_v23_11;
201  friend class Aspose::Pdf::Tests::RegressionTests_v24_01;
202  friend class Aspose::Pdf::Tests::InvalidFormTypeOperationExceptionTests;
203 
204 public:
205 
212  {
216  RenderFormAsUnsigned,
220  RenderFormAsSigned
221  };
222 
223 
224 public:
225 
229  class ASPOSE_PDF_SHARED_CLASS FlattenSettings : public System::Object
230  {
231  typedef FlattenSettings ThisType;
232  typedef System::Object BaseType;
233 
234  typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
235  ASPOSE_PDF_SHARED_RTTI_INFO_DECL();
236 
237  public:
238 
243  ASPOSE_PDF_SHARED_API bool get_UpdateAppearances() const;
248  ASPOSE_PDF_SHARED_API void set_UpdateAppearances(bool value);
252  ASPOSE_PDF_SHARED_API bool get_CallEvents() const;
256  ASPOSE_PDF_SHARED_API void set_CallEvents(bool value);
260  ASPOSE_PDF_SHARED_API bool get_HideButtons() const;
264  ASPOSE_PDF_SHARED_API void set_HideButtons(bool value);
268  ASPOSE_PDF_SHARED_API bool get_ApplyRedactions() const;
272  ASPOSE_PDF_SHARED_API void set_ApplyRedactions(bool value);
273 
274  ASPOSE_PDF_SHARED_API FlattenSettings();
275 
276  private:
277 
278  bool _hideButtons;
279  bool _updateAppearances;
280  bool _callEvents;
281  bool _applyRedactions;
282 
283  };
284 
285 
286 protected:
287 
288  class FieldsEnumerator : public System::Collections::Generic::IEnumerator<System::SharedPtr<Aspose::Pdf::Annotations::WidgetAnnotation>>
289  {
290  typedef FieldsEnumerator ThisType;
292 
293  typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
294  RTTI_INFO_DECL();
295  CODEPORTING_ENUMERATOR_ITERATOR_METHODS_DECLARATION(CODEPORTING_ARGS(System::SharedPtr<Aspose::Pdf::Annotations::WidgetAnnotation>), CODEPORTING_NO_API_KEYWORD);
296 
297  public:
298 
299  const System::SharedPtr<Aspose::Pdf::Annotations::WidgetAnnotation>& get_Current() const override;
300 
302 
303  bool MoveNext() override;
304  void Reset() override;
305  void Dispose() override;
306 
307  private:
308 
309  System::SharedPtr<Document> _document;
311  int32_t cursor;
312 
313  bool MoveNextImplementation();
315 
316  };
317 
318 
319 private:
320 
321  class XfaTestConversionData : public System::Object
322  {
323  typedef XfaTestConversionData ThisType;
324  typedef System::Object BaseType;
325 
326  typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
327  RTTI_INFO_DECL();
328 
329  public:
330 
338 
346  void SeekAllStreamsToZeroPosition();
348 
349  XfaTestConversionData();
350 
351  private:
352 
353  void AddEntryToZipWriterIfNotNull(System::SharedPtr<System::IO::MemoryStream> addedStream, System::String entryName, System::SharedPtr<Aspose::Pal::PalZipWriter> zipWriter);
354  void SeekStreamToBeginIfNotNull(System::SharedPtr<System::IO::MemoryStream> stream);
355 
356  };
357 
358 
359 public:
360 
364  ASPOSE_PDF_SHARED_API bool get_IsSynchronized();
368  ASPOSE_PDF_SHARED_API System::SharedPtr<System::Object> get_SyncRoot() const;
372  ASPOSE_PDF_SHARED_API bool get_AutoRecalculate() const;
376  ASPOSE_PDF_SHARED_API void set_AutoRecalculate(bool value);
380  ASPOSE_PDF_SHARED_API bool get_AutoRestoreForm() const;
384  ASPOSE_PDF_SHARED_API void set_AutoRestoreForm(bool value);
388  ASPOSE_PDF_SHARED_API System::SharedPtr<Resources> get_DefaultResources();
392  ASPOSE_PDF_SHARED_API System::SharedPtr<Aspose::Pdf::Annotations::DefaultAppearance> get_DefaultAppearance();
396  ASPOSE_PDF_SHARED_API void set_DefaultAppearance(System::SharedPtr<Aspose::Pdf::Annotations::DefaultAppearance> value);
400  ASPOSE_PDF_SHARED_API System::SharedPtr<Aspose::Pdf::Forms::XFA> get_XFA() const;
401 
409 
414  ASPOSE_PDF_SHARED_API bool get_IgnoreNeedsRendering() const;
419  ASPOSE_PDF_SHARED_API void set_IgnoreNeedsRendering(bool value);
426  ASPOSE_PDF_SHARED_API bool get_RemovePermission() const;
433  ASPOSE_PDF_SHARED_API void set_RemovePermission(bool value);
440  ASPOSE_PDF_SHARED_API bool get_EmulateRequierdGroups() const;
447  ASPOSE_PDF_SHARED_API void set_EmulateRequierdGroups(bool value);
451  ASPOSE_PDF_SHARED_API FormType get_Type();
455  ASPOSE_PDF_SHARED_API void set_Type(FormType value);
459  ASPOSE_PDF_SHARED_API System::ArrayPtr<System::SharedPtr<Field>> get_Fields();
463  ASPOSE_PDF_SHARED_API void set_CalculatedFields(System::SharedPtr<System::Collections::Generic::IEnumerable<System::SharedPtr<Field>>> value);
467  ASPOSE_PDF_SHARED_API bool get_SignaturesExist();
471  ASPOSE_PDF_SHARED_API void set_SignaturesExist(bool value);
476  ASPOSE_PDF_SHARED_API bool get_SignaturesAppendOnly();
481  ASPOSE_PDF_SHARED_API void set_SignaturesAppendOnly(bool value);
482 
488  ASPOSE_PDF_SHARED_API void CopyTo(System::ArrayPtr<System::SharedPtr<Field>> array, int32_t index);
498  ASPOSE_PDF_SHARED_API void Delete(System::SharedPtr<Field> field);
503  ASPOSE_PDF_SHARED_API void Delete(System::String fieldName);
507  ASPOSE_PDF_SHARED_API void Flatten();
508 
520  ASPOSE_PDF_SHARED_API System::SharedPtr<Aspose::Pdf::Annotations::WidgetAnnotation> idx_get(int32_t index);
521 
527  ASPOSE_PDF_SHARED_API void Add(System::SharedPtr<Field> field, int32_t pageNumber);
532  ASPOSE_PDF_SHARED_API void Add(const System::SharedPtr<Field>& field);
540  ASPOSE_PDF_SHARED_API System::SharedPtr<Field> Add(System::SharedPtr<Field> field, System::String partialName, int32_t pageNumber);
547  ASPOSE_PDF_SHARED_API void AddFieldAppearance(System::SharedPtr<Field> field, int32_t pageNumber, System::SharedPtr<Rectangle> rect);
554  ASPOSE_PDF_SHARED_API void RemoveFieldAppearance(System::SharedPtr<Field> field, int32_t appearanceIndex);
559  ASPOSE_PDF_SHARED_API void AssignXfa(System::SharedPtr<System::Xml::XmlDocument> xml);
567  ASPOSE_PDF_SHARED_API bool HasField(System::SharedPtr<Field> field);
575  ASPOSE_PDF_SHARED_API bool HasField(System::String fieldName);
587  ASPOSE_PDF_SHARED_API bool HasField(System::String fieldName, bool searchChildren);
593  ASPOSE_PDF_SHARED_API System::ArrayPtr<System::SharedPtr<Field>> GetFieldsInRect(System::SharedPtr<Rectangle> rect);
597  ASPOSE_PDF_SHARED_API int32_t get_Count() const override;
598 
599 protected:
600 
606  Aspose::Pdf::ApsToXpsSavingMode ApsToXpsSavingMode;
609 
610  bool get_HasXfa();
611 
614  void assertDefaultResources();
619  void ClearCache();
620 
622 
623  MEMBER_FUNCTION_MAKE_OBJECT_DECLARATION(Form, CODEPORTING_ARGS(System::SharedPtr<Document> document));
630  bool IsButton(System::SharedPtr<System::Xml::XmlNode> fieldTemplate);
631  void FlattenXfa(System::SharedPtr<Form::FlattenSettings> flattenSettings);
634  void addFieldToAcroForm(System::SharedPtr<Field> field);
635  System::SharedPtr<Field> DuplicateField(System::SharedPtr<Field> field, bool isNotSamePage);
636  void RemoveFieldFromAnnots(System::SharedPtr<Aspose::Pdf::Annotations::WidgetAnnotation> removedField);
637  System::SharedPtr<Resources> CreateDefaultResources();
638  void UpdateStaticFormAppearance(int32_t pageIndex);
639  void Recalculate();
644  bool RecalculateStep();
645 
646  virtual ASPOSE_PDF_SHARED_API ~Form();
647 
648 private:
649 
651  System::SharedPtr<Resources> defaultResources;
658  bool _autoRecalculate;
659  bool _autoRestoreForm;
660  bool _formFieldsRestored;
661 
662  int32_t get_Count_NonConst();
663 
664  bool pr_IgnoreNeedsRendering;
665  bool pr_RemovePermission;
666  bool pr_EmulateRequierdGroups;
667 
671  bool get_IsReadOnly() const override;
673  int32_t get_SignatureFlags();
674  void set_SignatureFlags(int32_t value);
675 
676  static int32_t _signaturesExist;
677  static int32_t _signaturesAppendOnly;
678 
680  static void PartitionFieldName(System::String fieldName, System::String& nameHead, System::String& nameTail);
684  void form_assert();
686  void ConvertDynamicXfaToStaticPdf();
689  static bool IsMustBeRenderedAsSignedDuringTypeConversion(System::SharedPtr<Form> form);
693  System::SharedPtr<System::IO::Stream> GetXfaFontStream(System::String resourceId);
694  void RemoveXfa();
695  void LoadCache();
698  void AddToCache(System::SharedPtr<Field> field);
708  void Clear() override;
713  bool Contains(const System::SharedPtr<Aspose::Pdf::Annotations::WidgetAnnotation>& field) const override;
719  void CopyTo(System::ArrayPtr<System::SharedPtr<Aspose::Pdf::Annotations::WidgetAnnotation>> array, int32_t arrayIndex) override;
725  bool Remove(const System::SharedPtr<Aspose::Pdf::Annotations::WidgetAnnotation>& field) override;
732  System::String GetUniqueFieldName(System::String prefix, bool includeZeroSuffix);
733  void CreateUniqueFieldNameWithGroupPrefix(System::SharedPtr<Field> field, System::SharedPtr<Aspose::Pdf::Annotations::WidgetAnnotation> existentWidgetAnnotation);
734  void ResolveExistentFieldName(System::SharedPtr<Field> field);
735  static bool HaveCommonParent(System::SharedPtr<Field> field, System::SharedPtr<Aspose::Pdf::Annotations::WidgetAnnotation> otherField);
744  bool Contains(System::SharedPtr<Rectangle> rect, System::SharedPtr<Rectangle> subRect) const;
746  void RestoreFormFieldsIfRequired();
747  void RestoreFormFields();
748  void SetSignatureFlag(int32_t flag);
749  void ClearSignatureFlag(int32_t flag);
750  void UpdateSignatureFlag(bool value, int32_t flag);
751  bool GetSignatureFlag(int32_t flag);
752 
753 };
754 
755 } // namespace Forms
756 } // namespace Pdf
757 } // namespace Aspose
758 
759 
String class used across the library. Is a substitute for C# System.String when translating code...
Definition: string.h:121
System::WeakPtr< Document > _document
Definition: Form.h:601
Class representing Acro form object.
Definition: Form.h:115
Class representing form object.
Definition: Form.h:157
Base class that enables using methods available for System.Object class in C#. All non-trivial classe...
Definition: object.h:64
Class representing PDF document
Definition: Document.h:621
Definition: Artifact.h:71
Form::SignDependentElementsRenderingModes SignDependentElementsRenderingModeWhenConverted
Forms can contain signing information, i.e. can be signed or unsigned. And form&#39;s view sometimes must...
Definition: Form.h:408
SignDependentElementsRenderingModes
Forms can contain signing information and can be signed or unsigned. Sometimes view of forms in viewe...
Definition: Form.h:211
Class which peroformes reading of XFDF format.
Definition: XfdfReader.h:63
System::String ZipFileToSaveConversionData
Definition: Form.h:608
System::String ApsModelPngSnapshotFileForTypeConversion
Definition: Form.h:605
Represents XML form regarding XML Forms Architecture (XFA).
Definition: XFA.h:83
Class which describes settings for Form flattening procedure.
Definition: Form.h:229
Class representing widget annotation.
Definition: WidgetAnnotation.h:88
System::String ApsModelXpsSnapshotFileForTypeConversion
Definition: Form.h:604
Definition: signed_info.h:13
FormType
Enumeration of posible types of Acro Form.
Definition: FormType.h:13
Base class for acro form fields.
Definition: Field.h:126
Represents a class to convert a pdf file&#39;s each page to images, supporting BMP, JPEG, PNG and TIFF now. Supported content in pdfs: pictures, form, comment.
Definition: PdfConverter.h:96
Class representing page resources.
Definition: Resources.h:267
Pointer class to wrap types being allocated on heap. Use it to manage memory for classes inheriting O...
Definition: SideBySidePdfComparer.h:24
means saving in XML format
Interface of enumerator which can be used to iterate through some elements. Objects of this class sho...
Definition: BaseOperatorCollection.h:47
Definition: AFRelationship.h:4
System::String ApsModelSnapshotFileForTypeConversion
Definition: Form.h:603
Subclass of System::SmartPtr which sets itself to weak mode at construction. Please note that this cl...
Definition: TextFragmentState.h:69
Class represents ListBox field.
Definition: ListBoxField.h:54
Interface of collection of elements. Objects of this class should only be allocated using System::Mak...
Definition: Collection.h:41
List forward declaration.
Definition: Artifact.h:78
System::SharedPtr< Aspose::Pdf::Forms::XFA > _xfa
Definition: Form.h:602
Represents a class to sign a pdf file with a certificate.
Definition: PdfFileSignature.h:64
Implements operations with PDF file: concatenation, splitting, extracting pages, making booklet...
Definition: PdfFileEditor.h:105
Aspose::Pdf::ApsToXpsSavingMode ApsToXpsSavingMode
Definition: Form.h:606
bool useRadiobuttonExtendedAttibsWhenConvertedToStandardForm
Definition: Form.h:607
Interface of object providing enumerator on contained elements.
Definition: Document.h:589
Collection of PDF document pages.
Definition: PageCollection.h:136
XfaTag
The xfa stream tag
Definition: XfaTag.h:11
class to handle related data incapsulation
Definition: XfaParserOptions.h:33
Class for editing forms (ading/deleting field etc)
Definition: FormEditor.h:73