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 IO
60 {
61 namespace ConvertStrategies
62 {
63 namespace ConvertHelpers
64 {
65 class FormExportImportUtils;
66 } // namespace ConvertHelpers
67 } // namespace ConvertStrategies
68 } // namespace IO
69 } // namespace Engine
70 namespace Facades
71 {
72 class Form;
73 class FormEditor;
74 class PdfConverter;
75 class PdfFileEditor;
76 class PdfFileSignature;
77 } // namespace Facades
78 namespace Forms
79 {
80 class Field;
81 enum class FormType;
82 class ListBoxField;
83 class XFA;
84 } // namespace Forms
85 namespace InteractiveFeatures
86 {
87 namespace Forms
88 {
89 class WidgetWrapper;
90 } // namespace Forms
91 } // namespace InteractiveFeatures
92 class PageCollection;
93 class PageGenerator;
94 namespace Plugins
95 {
96 class FormEditor;
97 class FormFlattener;
98 } // namespace Plugins
99 class Rectangle;
100 class Resources;
101 namespace Tests
102 {
103 class InvalidFormTypeOperationExceptionTests;
104 class RegressionTests_v10_8;
105 class RegressionTests_v16_12;
106 class RegressionTests_v17_12;
107 class RegressionTests_v18_5;
108 class RegressionTests_v20_01;
109 class RegressionTests_v23_11;
110 class RegressionTests_v24_01;
111 class RegressionTests_v6_9;
112 class RegressionTests_v7_1;
113 class RegressionTests_v7_4;
114 class RegressionTests_v7_7;
115 class RegressionTests_v7_8;
116 class RegressionTests_v7_9;
117 class RegressionTests_v8_2;
118 class RegressionTests_v8_8;
119 class RegressionTests_v9_1;
120 class XfaRendererTests;
121 } // namespace Tests
122 namespace XfaConverter
123 {
124 class XfaParserOptions;
125 } // namespace XfaConverter
126 class XfaMerge;
127 enum class XfaTag;
128 class XfaToPdfConverter;
129 } // namespace Pdf
130 namespace XfaRenderer
131 {
132 namespace Core
133 {
134 class XfaFontCash;
135 } // namespace Core
136 } // namespace XfaRenderer
137 } // namespace Aspose
138 namespace System
139 {
140 namespace Collections
141 {
142 namespace Generic
143 {
144 template <typename, typename> class Dictionary;
145 template <typename> class HashSet;
146 template <typename> class IEnumerable;
147 template <typename> class List;
148 } // namespace Generic
149 } // namespace Collections
150 namespace IO
151 {
152 class MemoryStream;
153 class Stream;
154 } // namespace IO
155 class Uri;
156 namespace Xml
157 {
158 class XmlDocument;
159 class XmlNode;
160 } // namespace Xml
161 } // namespace System
162 
163 namespace Aspose {
164 
165 namespace Pdf {
166 
167 namespace Forms {
168 
172 class ASPOSE_PDF_SHARED_CLASS Form final : public System::Collections::Generic::ICollection<System::SharedPtr<Aspose::Pdf::Annotations::WidgetAnnotation>>
173 {
174  typedef Form ThisType;
176 
177  typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
178  ASPOSE_PDF_SHARED_RTTI_INFO_DECL();
179 
180  friend class Aspose::Pdf::ApsToPdfConverter;
181  friend class Aspose::Pdf::Engine::CommonData::Text::Fonts::Utilities::DocumentFontsIterator;
182  friend class Aspose::Pdf::PageGenerator;
183  friend class Aspose::Pdf::Document;
194  friend class Aspose::Pdf::Annotations::XfdfWriter;
197  friend class Aspose::Pdf::XfaToPdfConverter;
198  friend class Aspose::Pdf::XfaMerge;
199  friend class Aspose::Pdf::Annotations::JavascriptExtensions::ThisObjectExtension;
202  friend class Aspose::Pdf::Engine::IO::ConvertStrategies::ConvertHelpers::FormExportImportUtils;
203  friend class Aspose::Pdf::Tests::XfaRendererTests;
204  friend class Aspose::Pdf::Tests::RegressionTests_v9_1;
205  friend class Aspose::Pdf::Tests::RegressionTests_v16_12;
206  friend class Aspose::Pdf::Tests::RegressionTests_v18_5;
207  friend class Aspose::Pdf::Tests::RegressionTests_v6_9;
208  friend class Aspose::Pdf::Tests::RegressionTests_v7_1;
209  friend class Aspose::Pdf::Tests::RegressionTests_v7_4;
210  friend class Aspose::Pdf::Tests::RegressionTests_v7_7;
211  friend class Aspose::Pdf::Tests::RegressionTests_v7_8;
212  friend class Aspose::Pdf::Tests::RegressionTests_v7_9;
213  friend class Aspose::Pdf::Tests::RegressionTests_v8_2;
214  friend class Aspose::Pdf::Tests::RegressionTests_v8_8;
215  friend class Aspose::Pdf::Tests::RegressionTests_v10_8;
216  friend class Aspose::Pdf::Tests::RegressionTests_v17_12;
217  friend class Aspose::Pdf::Tests::RegressionTests_v20_01;
218  friend class Aspose::Pdf::Tests::RegressionTests_v23_11;
219  friend class Aspose::Pdf::Tests::RegressionTests_v24_01;
220  friend class Aspose::Pdf::Tests::InvalidFormTypeOperationExceptionTests;
221 
222 public:
223 
230  {
234  RenderFormAsUnsigned,
238  RenderFormAsSigned
239  };
240 
241 
242 public:
243 
247  class ASPOSE_PDF_SHARED_CLASS FlattenSettings : public System::Object
248  {
249  typedef FlattenSettings ThisType;
250  typedef System::Object BaseType;
251 
252  typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
253  ASPOSE_PDF_SHARED_RTTI_INFO_DECL();
254 
255  public:
256 
261  ASPOSE_PDF_SHARED_API bool get_UpdateAppearances() const;
266  ASPOSE_PDF_SHARED_API void set_UpdateAppearances(bool value);
270  ASPOSE_PDF_SHARED_API bool get_CallEvents() const;
274  ASPOSE_PDF_SHARED_API void set_CallEvents(bool value);
278  ASPOSE_PDF_SHARED_API bool get_HideButtons() const;
282  ASPOSE_PDF_SHARED_API void set_HideButtons(bool value);
286  ASPOSE_PDF_SHARED_API bool get_ApplyRedactions() const;
290  ASPOSE_PDF_SHARED_API void set_ApplyRedactions(bool value);
291 
292  ASPOSE_PDF_SHARED_API FlattenSettings();
293 
294  private:
295 
296  bool _hideButtons;
297  bool _updateAppearances;
298  bool _callEvents;
299  bool _applyRedactions;
300 
301  };
302 
303 
304 protected:
305 
306  class FieldsEnumerator : public System::Collections::Generic::IEnumerator<System::SharedPtr<Aspose::Pdf::Annotations::WidgetAnnotation>>
307  {
308  typedef FieldsEnumerator ThisType;
310 
311  typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
312  RTTI_INFO_DECL();
313  CODEPORTING_ENUMERATOR_ITERATOR_METHODS_DECLARATION(CODEPORTING_ARGS(System::SharedPtr<Aspose::Pdf::Annotations::WidgetAnnotation>), CODEPORTING_NO_API_KEYWORD);
314 
315  public:
316 
317  const System::SharedPtr<Aspose::Pdf::Annotations::WidgetAnnotation>& get_Current() const override;
318 
320 
321  bool MoveNext() override;
322  void Reset() override;
323  void Dispose() override;
324 
325  private:
326 
327  System::SharedPtr<Document> _document;
329  int32_t cursor;
330 
331  bool MoveNextImplementation();
333 
334  };
335 
336 
337 private:
338 
339  class XfaTestConversionData : public System::Object
340  {
341  typedef XfaTestConversionData ThisType;
342  typedef System::Object BaseType;
343 
344  typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
345  RTTI_INFO_DECL();
346 
347  public:
348 
356 
364  void SeekAllStreamsToZeroPosition();
366 
367  XfaTestConversionData();
368 
369  private:
370 
371  void AddEntryToZipWriterIfNotNull(System::SharedPtr<System::IO::MemoryStream> addedStream, System::String entryName, System::SharedPtr<Aspose::Pal::PalZipWriter> zipWriter);
372  void SeekStreamToBeginIfNotNull(System::SharedPtr<System::IO::MemoryStream> stream);
373 
374  };
375 
376 
377 public:
378 
382  ASPOSE_PDF_SHARED_API bool get_IsSynchronized();
386  ASPOSE_PDF_SHARED_API System::SharedPtr<System::Object> get_SyncRoot() const;
390  ASPOSE_PDF_SHARED_API bool get_AutoRecalculate() const;
394  ASPOSE_PDF_SHARED_API void set_AutoRecalculate(bool value);
398  ASPOSE_PDF_SHARED_API bool get_AutoRestoreForm() const;
402  ASPOSE_PDF_SHARED_API void set_AutoRestoreForm(bool value);
406  ASPOSE_PDF_SHARED_API System::SharedPtr<Resources> get_DefaultResources();
410  ASPOSE_PDF_SHARED_API System::SharedPtr<Aspose::Pdf::Annotations::DefaultAppearance> get_DefaultAppearance();
414  ASPOSE_PDF_SHARED_API void set_DefaultAppearance(System::SharedPtr<Aspose::Pdf::Annotations::DefaultAppearance> value);
418  ASPOSE_PDF_SHARED_API System::SharedPtr<Aspose::Pdf::Forms::XFA> get_XFA() const;
419 
427 
432  ASPOSE_PDF_SHARED_API bool get_IgnoreNeedsRendering() const;
437  ASPOSE_PDF_SHARED_API void set_IgnoreNeedsRendering(bool value);
444  ASPOSE_PDF_SHARED_API bool get_RemovePermission() const;
451  ASPOSE_PDF_SHARED_API void set_RemovePermission(bool value);
458  ASPOSE_PDF_SHARED_API bool get_EmulateRequierdGroups() const;
465  ASPOSE_PDF_SHARED_API void set_EmulateRequierdGroups(bool value);
469  ASPOSE_PDF_SHARED_API FormType get_Type();
473  ASPOSE_PDF_SHARED_API void set_Type(FormType value);
477  ASPOSE_PDF_SHARED_API System::ArrayPtr<System::SharedPtr<Field>> get_Fields();
481  ASPOSE_PDF_SHARED_API void set_CalculatedFields(System::SharedPtr<System::Collections::Generic::IEnumerable<System::SharedPtr<Field>>> value);
485  ASPOSE_PDF_SHARED_API bool get_SignaturesExist();
489  ASPOSE_PDF_SHARED_API void set_SignaturesExist(bool value);
494  ASPOSE_PDF_SHARED_API bool get_SignaturesAppendOnly();
499  ASPOSE_PDF_SHARED_API void set_SignaturesAppendOnly(bool value);
500 
506  ASPOSE_PDF_SHARED_API void CopyTo(System::ArrayPtr<System::SharedPtr<Field>> array, int32_t index);
516  ASPOSE_PDF_SHARED_API void Delete(System::SharedPtr<Field> field);
521  ASPOSE_PDF_SHARED_API void Delete(System::String fieldName);
525  ASPOSE_PDF_SHARED_API void Flatten();
526 
538  ASPOSE_PDF_SHARED_API System::SharedPtr<Aspose::Pdf::Annotations::WidgetAnnotation> idx_get(int32_t index);
539 
545  ASPOSE_PDF_SHARED_API void Add(System::SharedPtr<Field> field, int32_t pageNumber);
550  ASPOSE_PDF_SHARED_API void Add(const System::SharedPtr<Field>& field);
558  ASPOSE_PDF_SHARED_API System::SharedPtr<Field> Add(System::SharedPtr<Field> field, System::String partialName, int32_t pageNumber);
565  ASPOSE_PDF_SHARED_API void AddFieldAppearance(System::SharedPtr<Field> field, int32_t pageNumber, System::SharedPtr<Rectangle> rect);
572  ASPOSE_PDF_SHARED_API void RemoveFieldAppearance(System::SharedPtr<Field> field, int32_t appearanceIndex);
577  ASPOSE_PDF_SHARED_API void AssignXfa(System::SharedPtr<System::Xml::XmlDocument> xml);
585  ASPOSE_PDF_SHARED_API bool HasField(System::SharedPtr<Field> field);
593  ASPOSE_PDF_SHARED_API bool HasField(System::String fieldName);
605  ASPOSE_PDF_SHARED_API bool HasField(System::String fieldName, bool searchChildren);
611  ASPOSE_PDF_SHARED_API System::ArrayPtr<System::SharedPtr<Field>> GetFieldsInRect(System::SharedPtr<Rectangle> rect);
615  ASPOSE_PDF_SHARED_API int32_t get_Count() const override;
616 
617 protected:
618 
624  Aspose::Pdf::ApsToXpsSavingMode ApsToXpsSavingMode;
627 
628  bool get_HasXfa();
629 
632  void assertDefaultResources();
637  void ClearCache();
638 
640 
641  MEMBER_FUNCTION_MAKE_OBJECT_DECLARATION(Form, CODEPORTING_ARGS(System::SharedPtr<Document> document));
648  bool IsButton(System::SharedPtr<System::Xml::XmlNode> fieldTemplate);
649  void FlattenXfa(System::SharedPtr<Form::FlattenSettings> flattenSettings);
652  void addFieldToAcroForm(System::SharedPtr<Field> field);
653  System::SharedPtr<Field> DuplicateField(System::SharedPtr<Field> field, bool isNotSamePage);
654  void RemoveFieldFromAnnots(System::SharedPtr<Aspose::Pdf::Annotations::WidgetAnnotation> removedField);
655  System::SharedPtr<Resources> CreateDefaultResources();
656  void UpdateStaticFormAppearance(int32_t pageIndex);
657  void Recalculate();
662  bool RecalculateStep();
663 
664  virtual ASPOSE_PDF_SHARED_API ~Form();
665 
666 private:
667 
669  System::SharedPtr<Resources> defaultResources;
676  bool _autoRecalculate;
677  bool _autoRestoreForm;
678  bool _formFieldsRestored;
679 
680  int32_t get_Count_NonConst();
681 
682  bool pr_IgnoreNeedsRendering;
683  bool pr_RemovePermission;
684  bool pr_EmulateRequierdGroups;
685 
689  bool get_IsReadOnly() const override;
691  int32_t get_SignatureFlags();
692  void set_SignatureFlags(int32_t value);
693 
694  static int32_t _signaturesExist;
695  static int32_t _signaturesAppendOnly;
696 
698  static void PartitionFieldName(System::String fieldName, System::String& nameHead, System::String& nameTail);
702  void form_assert();
704  void ConvertDynamicXfaToStaticPdf();
707  static bool IsMustBeRenderedAsSignedDuringTypeConversion(System::SharedPtr<Form> form);
711  System::SharedPtr<System::IO::Stream> GetXfaFontStream(System::String resourceId);
712  void RemoveXfa();
713  void LoadCache();
716  void AddToCache(System::SharedPtr<Field> field);
726  void Clear() override;
731  bool Contains(const System::SharedPtr<Aspose::Pdf::Annotations::WidgetAnnotation>& field) const override;
737  void CopyTo(System::ArrayPtr<System::SharedPtr<Aspose::Pdf::Annotations::WidgetAnnotation>> array, int32_t arrayIndex) override;
743  bool Remove(const System::SharedPtr<Aspose::Pdf::Annotations::WidgetAnnotation>& field) override;
750  System::String GetUniqueFieldName(System::String prefix, bool includeZeroSuffix);
751  void CreateUniqueFieldNameWithGroupPrefix(System::SharedPtr<Field> field, System::SharedPtr<Aspose::Pdf::Annotations::WidgetAnnotation> existentWidgetAnnotation);
752  void ResolveExistentFieldName(System::SharedPtr<Field> field);
753  static bool HaveCommonParent(System::SharedPtr<Field> field, System::SharedPtr<Aspose::Pdf::Annotations::WidgetAnnotation> otherField);
762  bool Contains(System::SharedPtr<Rectangle> rect, System::SharedPtr<Rectangle> subRect) const;
764  void RestoreFormFieldsIfRequired();
765  void RestoreFormFields();
766  void SetSignatureFlag(int32_t flag);
767  void ClearSignatureFlag(int32_t flag);
768  void UpdateSignatureFlag(bool value, int32_t flag);
769  bool GetSignatureFlag(int32_t flag);
770 
771 };
772 
773 } // namespace Forms
774 } // namespace Pdf
775 } // namespace Aspose
776 
777 
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:619
Class representing Acro form object.
Definition: Form.h:115
Class representing form object.
Definition: Form.h:172
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:625
Definition: Artifact.h:67
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:426
SignDependentElementsRenderingModes
Forms can contain signing information and can be signed or unsigned. Sometimes view of forms in viewe...
Definition: Form.h:229
Class which peroformes reading of XFDF format.
Definition: XfdfReader.h:63
System::String ZipFileToSaveConversionData
Definition: Form.h:626
System::String ApsModelPngSnapshotFileForTypeConversion
Definition: Form.h:623
Represents XML form regarding XML Forms Architecture (XFA).
Definition: XFA.h:93
Class which describes settings for Form flattening procedure.
Definition: Form.h:247
Class representing widget annotation.
Definition: WidgetAnnotation.h:93
System::String ApsModelXpsSnapshotFileForTypeConversion
Definition: Form.h:622
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:130
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:94
Class representing page resources.
Definition: Resources.h:257
Pointer class to wrap types being allocated on heap. Use it to manage memory for classes inheriting O...
Definition: fwd.h:22
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:621
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
Represents FormFlattener plugin.
Definition: FormFlattener.h:29
Represents FormEditor plugin.
Definition: FormEditor.h:32
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:74
System::SharedPtr< Aspose::Pdf::Forms::XFA > _xfa
Definition: Form.h:620
Represents a class to sign a pdf file with a certificate.
Definition: PdfFileSignature.h:63
Implements operations with PDF file: concatenation, splitting, extracting pages, making booklet...
Definition: PdfFileEditor.h:105
Aspose::Pdf::ApsToXpsSavingMode ApsToXpsSavingMode
Definition: Form.h:624
bool useRadiobuttonExtendedAttibsWhenConvertedToStandardForm
Definition: Form.h:625
Interface of object providing enumerator on contained elements.
Definition: Document.h:593
Collection of PDF document pages.
Definition: PageCollection.h:135
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