PdfContentEditor.h
1 #pragma once
2 // Copyright (c) 2001-2024 Aspose Pty Ltd. All Rights Reserved.
3 
4 #include <system/array.h>
5 #include <cstdint>
6 
7 #include "Aspose.PDF.Cpp/Facades/Facade.h"
8 #include "Aspose.PDF.Cpp/aspose_pdf_api_defs.h"
9 
10 namespace Aspose
11 {
12 namespace Pdf
13 {
14 namespace Annotations
15 {
16 class Annotation;
17 class PdfAction;
18 } // namespace Annotations
19 namespace Collections
20 {
21 template <typename, typename> class AsposeHashDictionary;
22 } // namespace Collections
23 class Document;
24 namespace Engine
25 {
26 namespace Data
27 {
28 class IPdfDictionary;
29 class IPdfObject;
30 } // namespace Data
31 } // namespace Engine
32 namespace Facades
33 {
34 class LineInfo;
35 class PdfContentEditor;
36 class ReplaceTextStrategy;
37 class StampInfo;
38 enum class StampType;
39 } // namespace Facades
40 class Matrix;
41 class Operator;
42 class OperatorCollection;
43 class Page;
44 class Rectangle;
45 class Resources;
46 namespace Text
47 {
48 class TextEditOptions;
49 class TextReplaceOptions;
50 class TextSearchOptions;
51 class TextState;
52 } // namespace Text
53 class XForm;
54 class XImage;
55 } // namespace Pdf
56 } // namespace Aspose
57 namespace System
58 {
59 class BoxedValueBase;
60 namespace Collections
61 {
62 namespace Generic
63 {
64 template <typename> class IList;
65 template <typename> class List;
66 } // namespace Generic
67 } // namespace Collections
68 namespace Drawing
69 {
70 class Color;
71 class Rectangle;
72 } // namespace Drawing
73 class EventArgs;
74 namespace IO
75 {
76 class Stream;
77 } // namespace IO
78 } // namespace System
79 
80 namespace Aspose {
81 
82 namespace Pdf {
83 
84 namespace Facades {
85 
89 class ASPOSE_PDF_SHARED_CLASS PdfContentEditor final : public Aspose::Pdf::Facades::SaveableFacade
90 {
91  typedef PdfContentEditor ThisType;
93 
94  typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
95  ASPOSE_PDF_SHARED_RTTI_INFO_DECL();
96 
97 private:
98 
102  class StampData : public System::Object
103  {
104  typedef StampData ThisType;
105  typedef System::Object BaseType;
106 
107  typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
108  RTTI_INFO_DECL();
109 
110  public:
111 
112  System::String get_Name() const;
117  bool get_Visible() const;
119  Aspose::Pdf::Facades::StampType get_StampType();
120  System::SharedPtr<XImage> get_Image();
121  System::SharedPtr<XForm> get_Form();
122  int32_t get_StampId();
123 
126 
133  bool Move(double X, double Y);
138  bool Delete();
143  bool Hide();
148  bool Show();
149 
150  private:
151 
152  System::SharedPtr<Page> _ownerPage;
153  System::SharedPtr<XForm> _ownerForm;
154  System::String _name;
158  bool _visible;
160 
163  System::SharedPtr<Resources> GetResources();
165  bool Delete(bool removeResource);
166 
167  };
168 
169 
170 public:
171 
175  ASPOSE_PDF_SHARED_API System::SharedPtr<Aspose::Pdf::Text::TextSearchOptions> get_TextSearchOptions() const;
179  ASPOSE_PDF_SHARED_API void set_TextSearchOptions(System::SharedPtr<Aspose::Pdf::Text::TextSearchOptions> value);
183  ASPOSE_PDF_SHARED_API System::SharedPtr<Aspose::Pdf::Text::TextEditOptions> get_TextEditOptions() const;
187  ASPOSE_PDF_SHARED_API void set_TextEditOptions(System::SharedPtr<Aspose::Pdf::Text::TextEditOptions> value);
191  ASPOSE_PDF_SHARED_API System::SharedPtr<Aspose::Pdf::Text::TextReplaceOptions> get_TextReplaceOptions() const;
195  ASPOSE_PDF_SHARED_API void set_TextReplaceOptions(System::SharedPtr<Aspose::Pdf::Text::TextReplaceOptions> value);
199  ASPOSE_PDF_SHARED_API System::SharedPtr<Aspose::Pdf::Facades::ReplaceTextStrategy> get_ReplaceTextStrategy() const;
203  ASPOSE_PDF_SHARED_API void set_ReplaceTextStrategy(System::SharedPtr<Aspose::Pdf::Facades::ReplaceTextStrategy> value);
204 
208  static const ASPOSE_PDF_SHARED_API System::String DocumentOpen;
212  static const ASPOSE_PDF_SHARED_API System::String DocumentClose;
216  static const ASPOSE_PDF_SHARED_API System::String DocumentWillSave;
220  static const ASPOSE_PDF_SHARED_API System::String DocumentSaved;
224  static const ASPOSE_PDF_SHARED_API System::String DocumentWillPrint;
228  static const ASPOSE_PDF_SHARED_API System::String DocumentPrinted;
229 
234  ASPOSE_PDF_SHARED_API void BindPdf(System::String inputFile) override;
239  ASPOSE_PDF_SHARED_API void BindPdf(System::SharedPtr<System::IO::Stream> inputStream) override;
257  ASPOSE_PDF_SHARED_API void CreateWebLink(System::Drawing::Rectangle rect, System::String url, int32_t originalPage, System::Drawing::Color clr, System::ArrayPtr<System::SharedPtr<System::BoxedValueBase>> actionName);
267  ASPOSE_PDF_SHARED_API void CreateWebLink(System::Drawing::Rectangle rect, System::String url, int32_t originalPage, System::Drawing::Color clr);
276  ASPOSE_PDF_SHARED_API void CreateWebLink(System::Drawing::Rectangle rect, System::String url, int32_t originalPage);
287  ASPOSE_PDF_SHARED_API void CreateLocalLink(System::Drawing::Rectangle rect, int32_t desPage, int32_t originalPage, System::Drawing::Color clr, System::ArrayPtr<System::SharedPtr<System::BoxedValueBase>> actionName);
297  ASPOSE_PDF_SHARED_API void CreateLocalLink(System::Drawing::Rectangle rect, int32_t desPage, int32_t originalPage, System::Drawing::Color clr);
309  ASPOSE_PDF_SHARED_API void CreatePdfDocumentLink(System::Drawing::Rectangle rect, System::String remotePdf, int32_t originalPage, int32_t destinationPage, System::Drawing::Color clr, System::ArrayPtr<System::SharedPtr<System::BoxedValueBase>> actionName);
320  ASPOSE_PDF_SHARED_API void CreatePdfDocumentLink(System::Drawing::Rectangle rect, System::String remotePdf, int32_t originalPage, int32_t destinationPage, System::Drawing::Color clr);
330  ASPOSE_PDF_SHARED_API void CreatePdfDocumentLink(System::Drawing::Rectangle rect, System::String remotePdf, int32_t originalPage, int32_t destinationPage);
340  ASPOSE_PDF_SHARED_API void CreateCustomActionLink(System::Drawing::Rectangle rect, int32_t originalPage, System::Drawing::Color color, System::ArrayPtr<System::SharedPtr<System::BoxedValueBase>> actionName);
351  ASPOSE_PDF_SHARED_API void CreateApplicationLink(System::Drawing::Rectangle rect, System::String application, int32_t page, System::Drawing::Color clr, System::ArrayPtr<System::SharedPtr<System::BoxedValueBase>> actionName);
361  ASPOSE_PDF_SHARED_API void CreateApplicationLink(System::Drawing::Rectangle rect, System::String application, int32_t page, System::Drawing::Color clr);
370  ASPOSE_PDF_SHARED_API void CreateApplicationLink(System::Drawing::Rectangle rect, System::String application, int32_t page);
380  ASPOSE_PDF_SHARED_API void CreateJavaScriptLink(System::String code, System::Drawing::Rectangle rect, int32_t originalPage, System::Drawing::Color color);
393  ASPOSE_PDF_SHARED_API void CreateText(System::Drawing::Rectangle rect, System::String title, System::String contents, bool open, System::String icon, int32_t page);
402  ASPOSE_PDF_SHARED_API void CreateFreeText(System::Drawing::Rectangle rect, System::String contents, int32_t page);
413  ASPOSE_PDF_SHARED_API void CreateMarkup(System::Drawing::Rectangle rect, System::String contents, int32_t type, int32_t page, System::Drawing::Color clr);
423  ASPOSE_PDF_SHARED_API void CreatePopup(System::Drawing::Rectangle rect, System::String contents, bool open, int32_t page);
435  ASPOSE_PDF_SHARED_API void CreateFileAttachment(System::Drawing::Rectangle rect, System::String contents, System::String filePath, int32_t page, System::String name);
448  ASPOSE_PDF_SHARED_API void CreateFileAttachment(System::Drawing::Rectangle rect, System::String contents, System::String filePath, int32_t page, System::String name, double opacity);
461  ASPOSE_PDF_SHARED_API void CreateFileAttachment(System::Drawing::Rectangle rect, System::String contents, System::SharedPtr<System::IO::Stream> attachmentStream, System::String attachmentName, int32_t page, System::String name);
475  ASPOSE_PDF_SHARED_API void CreateFileAttachment(System::Drawing::Rectangle rect, System::String contents, System::SharedPtr<System::IO::Stream> attachmentStream, System::String attachmentName, int32_t page, System::String name, double opacity);
483  ASPOSE_PDF_SHARED_API void AddDocumentAttachment(System::String fileAttachmentPath, System::String description);
492  ASPOSE_PDF_SHARED_API void AddDocumentAttachment(System::SharedPtr<System::IO::Stream> fileAttachmentStream, System::String fileAttachmentName, System::String description);
498  ASPOSE_PDF_SHARED_API void DeleteAttachments();
519  ASPOSE_PDF_SHARED_API void CreateLine(System::Drawing::Rectangle rect, System::String contents, float x1, float y1, float x2, float y2, int32_t page, int32_t border, System::Drawing::Color clr, System::String borderStyle, System::ArrayPtr<int32_t> dashArray, System::ArrayPtr<System::String> LEArray);
531  ASPOSE_PDF_SHARED_API void CreateSquareCircle(System::Drawing::Rectangle rect, System::String contents, System::Drawing::Color clr, bool square, int32_t page, int32_t borderWidth);
541  ASPOSE_PDF_SHARED_API void DrawCurve(System::SharedPtr<LineInfo> lineInfo, int32_t page, System::Drawing::Rectangle annotRect, System::String annotContents);
551  ASPOSE_PDF_SHARED_API void CreatePolygon(System::SharedPtr<LineInfo> lineInfo, int32_t page, System::Drawing::Rectangle annotRect, System::String annotContents);
561  ASPOSE_PDF_SHARED_API void CreatePolyLine(System::SharedPtr<LineInfo> lineInfo, int32_t page, System::Drawing::Rectangle annotRect, System::String annotContents);
573  ASPOSE_PDF_SHARED_API void CreateCaret(int32_t page, System::Drawing::Rectangle annotRect, System::Drawing::Rectangle caretRect, System::String symbol, System::String annotContents, System::Drawing::Color color);
584  ASPOSE_PDF_SHARED_API void CreateRubberStamp(int32_t page, System::Drawing::Rectangle annotRect, System::String icon, System::String annotContents, System::Drawing::Color color);
595  ASPOSE_PDF_SHARED_API void CreateRubberStamp(int32_t page, System::Drawing::Rectangle annotRect, System::String annotContents, System::Drawing::Color color, System::String appearanceFile);
606  ASPOSE_PDF_SHARED_API void CreateRubberStamp(int32_t page, System::Drawing::Rectangle annotRect, System::String annotContents, System::Drawing::Color color, System::SharedPtr<System::IO::Stream> appearanceStream);
619  ASPOSE_PDF_SHARED_API void CreateBookmarksAction(System::String title, System::Drawing::Color color, bool boldFlag, bool italicFlag, System::String file, System::String actionType, System::String destination);
627  ASPOSE_PDF_SHARED_API void AddDocumentAdditionalAction(System::String eventType, System::String code);
633  ASPOSE_PDF_SHARED_API void RemoveDocumentOpenAction();
640  ASPOSE_PDF_SHARED_API void ChangeViewerPreference(int32_t viewerAttribution);
647  ASPOSE_PDF_SHARED_API int32_t GetViewerPreference();
656  ASPOSE_PDF_SHARED_API void ReplaceImage(int32_t pageNumber, int32_t index, System::String imageFile);
664  ASPOSE_PDF_SHARED_API void DeleteImage(int32_t pageNumber, System::ArrayPtr<int32_t> index);
670  ASPOSE_PDF_SHARED_API void DeleteImage();
681  ASPOSE_PDF_SHARED_API bool ReplaceText(System::String srcString, int32_t thePage, System::String destString, System::SharedPtr<Aspose::Pdf::Text::TextState> textState);
690  ASPOSE_PDF_SHARED_API bool ReplaceText(System::String srcString, System::String destString);
700  ASPOSE_PDF_SHARED_API bool ReplaceText(System::String srcString, int32_t thePage, System::String destString);
710  ASPOSE_PDF_SHARED_API bool ReplaceText(System::String srcString, System::String destString, System::SharedPtr<Aspose::Pdf::Text::TextState> textState);
717  ASPOSE_PDF_SHARED_API void CreateMovie(System::Drawing::Rectangle rect, System::String filePath, int32_t page);
726  ASPOSE_PDF_SHARED_API void CreateSound(System::Drawing::Rectangle rect, System::String filePath, System::String name, int32_t page, System::String rate);
734  ASPOSE_PDF_SHARED_API void DeleteStamp(int32_t pageNumber, System::ArrayPtr<int32_t> index);
741  ASPOSE_PDF_SHARED_API void DeleteStampByIds(System::ArrayPtr<int32_t> stampIds);
749  ASPOSE_PDF_SHARED_API void DeleteStampByIds(int32_t pageNumber, System::ArrayPtr<int32_t> stampIds);
757  ASPOSE_PDF_SHARED_API void DeleteStampById(int32_t pageNumber, int32_t stampId);
763  ASPOSE_PDF_SHARED_API void HideStampById(int32_t pageNumber, int32_t stampId);
769  ASPOSE_PDF_SHARED_API void ShowStampById(int32_t pageNumber, int32_t stampId);
777  ASPOSE_PDF_SHARED_API void MoveStampById(int32_t pageNumber, int32_t stampId, double x, double y);
785  ASPOSE_PDF_SHARED_API void MoveStamp(int32_t pageNumber, int32_t stampIndex, double x, double y);
792  ASPOSE_PDF_SHARED_API void DeleteStampById(int32_t stampId);
793 
797  ASPOSE_PDF_SHARED_API PdfContentEditor();
804  ASPOSE_PDF_SHARED_API PdfContentEditor(System::SharedPtr<Aspose::Pdf::Document> document);
805 
814  ASPOSE_PDF_SHARED_API void CreateLocalLink(System::Drawing::Rectangle rect, int32_t desPage, int32_t originalPage);
824  ASPOSE_PDF_SHARED_API bool ReplaceText(System::String srcString, System::String destString, int32_t fontSize);
830  ASPOSE_PDF_SHARED_API System::ArrayPtr<System::SharedPtr<StampInfo>> GetStamps(int32_t pageNumber);
834  ASPOSE_PDF_SHARED_API void Close() override;
835 
836 protected:
837 
838  virtual ASPOSE_PDF_SHARED_API ~PdfContentEditor();
839 
840 private:
841 
847  static System::String HiddenStampTag;
848 
851  void ReplaceTextStrategy_OnPropertiesChanged(System::SharedPtr<System::Object> sender, System::SharedPtr<System::EventArgs> e);
852  void SyncOptionsWithReplaceTextStrategy();
861  bool CheckStampSignature(System::SharedPtr<OperatorCollection> contents, System::SharedPtr<Operator> op);
866  System::ArrayPtr<System::SharedPtr<PdfContentEditor::StampData>> GetStampsOnPage(int32_t pageIndex);
867  bool DeleteStampLogic(int32_t pageIndex, System::ArrayPtr<int32_t> stampIndex);
868  void ClearStampCache();
869  bool IsResourceInUse(System::SharedPtr<Aspose::Pdf::Engine::Data::IPdfObject> resource);
870 
871 };
872 
873 } // namespace Facades
874 } // namespace Pdf
875 } // namespace Aspose
876 
877 
static const ASPOSE_PDF_SHARED_API System::String DocumentOpen
A document event type. Opens a document.
Definition: PdfContentEditor.h:208
StampType
Describes stamp types.
Definition: StampType.h:13
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
static const ASPOSE_PDF_SHARED_API System::String DocumentWillPrint
A document event type. Excute a action before printing.
Definition: PdfContentEditor.h:224
Base class for all saveable facades.
Definition: Facade.h:151
Base class that enables using methods available for System.Object class in C#. All non-trivial classe...
Definition: object.h:64
Definition: Artifact.h:67
Base facade class.
Definition: Facade.h:57
static const ASPOSE_PDF_SHARED_API System::String DocumentClose
A document event type. Closes a document.
Definition: PdfContentEditor.h:212
Represents a rectangular area of an image defined as integer X and Y coordinates of its upper left co...
Definition: rectangle.h:18
Pointer class to wrap types being allocated on heap. Use it to manage memory for classes inheriting O...
Definition: fwd.h:22
General facade interface that defines common facades methods.
Definition: IFacade.h:33
static const ASPOSE_PDF_SHARED_API System::String DocumentWillSave
A document event type. Excute a action before saving.
Definition: PdfContentEditor.h:216
Definition: AFRelationship.h:4
Represents a color. This type should be allocated on stack and passed to functions by value or by ref...
Definition: color.h:23
Subclass of System::SmartPtr which sets itself to weak mode at construction. Please note that this cl...
Definition: TextFragmentState.h:69
static const ASPOSE_PDF_SHARED_API System::String DocumentPrinted
A document event type. Excute a action after printing.
Definition: PdfContentEditor.h:228
List forward declaration.
Definition: Artifact.h:74
The coordinates are in the page coordinate context.
Represents a class to edit PDF file&#39;s content.
Definition: PdfContentEditor.h:89
static const ASPOSE_PDF_SHARED_API System::String DocumentSaved
A document event type. Excute a action after saving.
Definition: PdfContentEditor.h:220
Whole PDF file will be submitted.