Foxit PDF SDK
fs_ofddoc.h
1 #ifndef FS_OFD_DOC_H_
2 #define FS_OFD_DOC_H_
3 
4 #include "common/fs_common.h"
5 #include "common/fs_image.h"
6 
12 namespace foxit {
13 namespace fld {
14 class FLDDoc;
15 }
19 namespace ofd {
20 class OFDPage;
21 class OFDTemplatePage;
22 class Catalog;
23 class Bookmarks;
24 class CustomTags;
25 class TagTreeNode;
26 class Outline;
27 class Attachments;
28 class Attachment;
29 class OFDPermission;
30 class Annots;
34 namespace ofdseal {
35 class Signature;
36 }
37 
39 class PageNumberParameter FS_FINAL : public Object {
40  public:
46  typedef enum _PageNumberLocationType {
60 
66  typedef enum _PageNumberMarginType {
74 
75 
81  font_name(L"宋体"),
82  font_size(12),
83  text_color(0),
84  start_page(0),
85  end_page(0),
86  is_first_page_cover(false),
88  is_folio(false),
90  skip_blank_page(false) {}
91 
126  margin(margin),
128 
135  this->location = other.location;
136  this->font_name = other.font_name;
137  this->font_size = other.font_size;
138  this->text_color = other.text_color;
139  this->start_page = other.start_page;
140  this->end_page = other.end_page;
142  this->first_page_number = other.first_page_number;
143  this->is_folio = other.is_folio;
144  this->margin = other.margin;
145  this->skip_blank_page = other.skip_blank_page;
146  }
147 
156  this->location = other.location;
157  this->font_name = other.font_name;
158  this->font_size = other.font_size;
159  this->text_color = other.text_color;
160  this->start_page = other.start_page;
161  this->end_page = other.end_page;
163  this->first_page_number = other.first_page_number;
164  this->is_folio = other.is_folio;
165  this->margin = other.margin;
166  this->skip_blank_page = other.skip_blank_page;
167  return *this;
168  }
169 
195  this->location = location;
196  this->font_name = font_name;
197  this->font_size = font_size;
198  this->text_color = text_color;
199  this->start_page = start_page;
200  this->end_page = end_page;
201  this->is_first_page_cover = is_first_page_cover;
202  this->first_page_number = first_page_number;
203  this->is_folio = is_folio;
204  this->margin = margin;
205  this->skip_blank_page = skip_blank_page;
206  }
207 
215 
220 
224  float font_size;
225 
230 
235 
239  int end_page;
240 
245 
250 
254  bool is_folio;
255 
263 
268 };
269 
271 class OFDDoc FS_FINAL : public Base {
272  public:
278  typedef enum _EncryptMethod {
285  } EncryptMethod;
286 
292  typedef enum _EncryptType {
303  } EncryptType;
304 
310  typedef enum _ResourceType {
323  } ResourceType;
324 
325 
331  explicit OFDDoc(const foxit::fld::FLDDoc& doc);
332 
334  ~OFDDoc();
335 
341  OFDDoc(const OFDDoc& other);
342 
350  OFDDoc& operator = (const OFDDoc& other);
351 
359  bool operator == (const OFDDoc& other) const;
360 
368  bool operator != (const OFDDoc& other) const;
369 
377  bool IsEmpty() const;
378 
384  int GetPageCount();
385 
394  OFDPage GetPage(int index);
395 
404 
410  OFDPage AddPage();
411 
420  OFDPage InsertPage(int index);
421 
430  void RemovePage(int index);
431 
440  void ReservedPage(int index);
441 
452  bool MovePage(int index, int dest_index);
453 
459  int GetTemplatePageCount();
460 
469  OFDTemplatePage GetTemplatePage(int index);
470 
479 
488 
498 
507  void RemoveTemplatePage(int index);
508 
514  void RemoveAllTemplatePages();
515 
522 
531 
543  OFDPage AddPageFromTemplatePage(int index, int dest_index = -1);
544 
551 
558 
564  int GetAttachmentCount();
565 
574  Attachment GetAttachment(int index);
575 
584 
593  String GetAttachmentBuffer(int index);
594 
604 
614  void ExportAttachment(int index, const String& file_path);
615 
625  void ExportAttachment(int index, const WString& file_path);
626 
636  void ExportAttachment(int index, foxit::common::file::WriterCallback* file_writer);
637 
647  Attachment AddAttachment(const String& file_name, const String& name = NULL, const String& usage = NULL);
648 
658  Attachment AddAttachment(const WString& file_name, const String& name = NULL, const String& usage = NULL);
659 
666 
676  bool SaveXmlFileAttachment(int index, const String& file_path);
677 
687  bool SaveXmlFileAttachment(int index, const WString& file_path);
688 
696  WString GetMetadata(const WString& key);
697 
706  void SetMetadata(const WString& key, const WString& value);
707 
713  int GetKeywordCount();
714 
723  void InsertKeyword(const WString& keyword, int index = -1);
724 
733  void RemoveKeyword(int index);
734 
740  int GetCustomDataCount();
741 
750  WString GetCustomDataName(int index);
751 
760  WString GetCustomDataValue(int index);
761 
770  void AddCustomData(const String& key, const String& value);
771 
781  void InsertCustomData(const String& key, const String& value, int index);
782 
791  void RemoveCustomData(int index);
792 
800  foxit::uint32 AddResourceFromFile(const String& file_path, const String& format);
801 
810  foxit::uint32 AddResourceFromFile(const WString& file_path, const String& format);
811 
820 
829 
841 
850  foxit::uint32 AddFontResourceFromName(const String& font_family, const String& font_name);
851 
861 
870 
879  void ExportMultiMediaByID(foxit::uint32 res_id, const String& file_path);
880 
889  void ExportMultiMediaByID(foxit::uint32 res_id, const WString& file_path);
890 
900 
909 
918 
927 
936 
944  void ExportAnnots(const String& file_path);
945 
957  void ExportAnnots(int start_index, int end_index, const String& file_path);
958 
966  void ImportAnnots(const String& file_path);
967 
975  void AddPageNumber(const PageNumberParameter& param);
976 
986  bool InsertDocument(const OFDDoc& other, int dest_index = -1);
987 
994 
1000  Outline GetOutline();
1001 
1007  bool RemoveOutline();
1008 
1016  bool AddCatalog(const Catalog& catalog);
1017 
1023  int GetSignatureCount();
1024 
1033  ofdseal::Signature GetSignature(int index);
1034 
1041 
1048 
1055 
1062 
1070  TagTreeNode GetTagTreeRoot(const String& type);
1071 
1083  void InitializeTagTreeNode(const String& type, const String& name_space, const String& name, const String& file_extension, bool key_unique);
1084 
1092  void InitializeCertTagTreeNode(bool key_unique);
1093 
1101  void BeginTagTreeNode(const String& key_path);
1102 
1111  void AddTagTreeNodeMetaData(const String& key, const String& value);
1112 
1120  void EndTagTreeNode(const String& key_path);
1121 
1127  void ClearTagTreeNode();
1128 
1136  bool ExportOfficeDoc(const String& file_path);
1137 
1145  bool ExportOfficeDoc(const WString& file_path);
1146 
1152  bool RestoreOriginalDocument();
1153 
1161  bool RefreshObjectsPermission(bool authenticated);
1162 
1174  bool CustomEncrypt(const String& security_type, const String& crypto_type, int key_length, const String& user_password, const String& owner_password);
1175 
1183  bool RemoveEncryption(const String& owner_password);
1184 
1191 
1198 
1207  void EmbedFont(const String& font_name);
1208 
1214  int GetVersionCount();
1215 
1224  void SetCurrentVersion(int index);
1225 
1231  void CreateVersion();
1232 
1233  explicit OFDDoc(FS_HANDLE handle = NULL);
1234 };
1235 
1236 } // namespace ofd
1237 } // namespace foxit
1238 
1239 #endif // FS_OFD_DOC_H_
void CreateVersion()
创建版本,并切换到该版本。只能创建一个版本。
CustomTags GetCustomTags()
获取自定义标签。
void ImportAnnots(const String &file_path)
导入注释。
OFDPage GetPage(int index)
获取OFD页面。
void SetCurrentVersion(int index)
设置当前版本。
void AddCustomData(const String &key, const String &value)
添加OFD自定义数据。
void InsertCustomData(const String &key, const String &value, int index)
插入OFD自定义数据。
文件写入接口。
Definition: fx_stream.h:470
OFDDoc & operator=(const OFDDoc &other)
赋值操作符。
Definition: fs_ofdbookmark.h:176
bool CustomEncrypt(const String &security_type, const String &crypto_type, int key_length, const String &user_password, const String &owner_password)
对文档进行自定义加密。必须先调用 OFDSecurity::RegisterHandler 方法注册自定义加密处理器。
CFX_Object Object
对象类型。
Definition: fs_basictypes.h:220
foxit::RGB text_color
页码文本颜色。
Definition: fs_ofddoc.h:229
OFDTemplatePage AddTemplatePage()
添加新的模板页面。
PageNumberParameter & operator=(const PageNumberParameter &other)
赋值操作符。
Definition: fs_ofddoc.h:155
加密类型:RC4。
Definition: fs_ofddoc.h:296
bool operator !=(const OFDDoc &other) const
不相等操作符。
foxit::common::file::ReaderCallback * GetAttachmentFile(int index)
获取OFD附件文件指针。
bool is_folio
是否为对开页面,true代表是对开页面,false代表不是。
Definition: fs_ofddoc.h:254
int GetVersionCount()
获取版本数量。
void BeginTagTreeNode(const String &key_path)
开始添加票据标引节点。
OFDPermission GetPermissions()
获取权限对象。
bool RemoveOutline()
删除所有大纲节点。
Definition: fs_ofdtagtreenode.h:21
bool is_first_page_cover
首页是否为封面,true代表首页,false代表非首页。
Definition: fs_ofddoc.h:244
int GetKeywordCount()
获取OFD Metadata项数量。
Definition: fs_ofdattachment.h:122
int GetCustomDataCount()
获取OFD自定义数据数量。
PageNumberParameter(const PageNumberParameter &other)
用另一个页码参数对象的构造函数。
Definition: fs_ofddoc.h:134
uint32 RGB
RGB 颜色类型,24 位,((b) | ((g) << 8) | ((r) << 16)))
Definition: fs_basictypes.h:211
bool ExportOfficeDoc(const String &file_path)
导出公文语义xml文件。
Attachments CreateAttachments()
创建OFD附件集合。
bool IsEmpty() const
检查当前对象是否为空。
Outline CreateOutline()
创建大纲。
WString GetCustomDataValue(int index)
获取OFD自定义值。
OFDTemplatePage InsertTemplatePage(int index)
插入模板页面。
文件读取接口。
Definition: fx_stream.h:587
foxit::uint32 AddResourceFromFile(const String &file_path, const String &format)
从文件添加资源到OFD文档。
int GetPageCount()
获取OFD文档页面数量。
WString GetMultiMediaFormatByID(foxit::uint32 res_id)
获取多媒体格式。
宽字符串类
Definition: fx_string.h:1457
WString GetMetadata(const WString &key)
获取OFD Metadata项。
OFDTemplatePage GetTemplatePageByID(int id)
获取OFD模板页面。
Attachments GetAttachments()
获取OFD附件集合。
Attachment GetAttachment(int index)
获取OFD附件对象。
ResourceType GetResourceTypeByID(foxit::uint32 res_id)
获取资源类型通过资源ID。
PageNumberMarginType
OFD添加页码边距枚举类型。
Definition: fs_ofddoc.h:66
~OFDDoc()
析构函数。
void ReservedPage(int index)
指定保存需要保留的OFD页面。保存后,未保留的页面将被删除。
Attachment GetAttachmentByName(const String &name)
获取OFD附件对象。
void Set(PageNumberLocationType location, const WString &font_name, float font_size, foxit::RGB text_color, int start_page, int end_page, bool is_first_page_cover, int first_page_number, bool is_folio, PageNumberMarginType margin, bool skip_blank_page)
设置值。
Definition: fs_ofddoc.h:193
void ExportAttachment(int index, const String &file_path)
保存附件到文件中。
加密类型:无。
Definition: fs_ofddoc.h:294
ResourceType
OFD资源类型枚举类型。
Definition: fs_ofddoc.h:310
加密方法:证书加密
Definition: fs_ofddoc.h:284
Definition: fs_ofdoutline.h:20
Definition: fs_ofdattachment.h:395
void RemoveCustomData(int index)
删除OFD自定义数据。
图像和位图相关定义和类的头文件。
bool MovePage(int index, int dest_index)
移动页面到指定索引。
void AddTagTreeNodeMetaData(const String &key, const String &value)
添加自定义票据标引树节点元数据。
Attachment AddAttachment(const String &file_name, const String &name=0, const String &usage=0)
添加附件。
OFDPage AddPageFromTemplatePage(int index, int dest_index=-1)
添加新的页面。
String GetAttachmentBuffer(int index)
获取OFD附件内存缓冲区。
int GetTemplatePageCount()
获取OFD文档模板页面数量。
void RemoveAllTemplatePages()
删除所有模板页面。
Definition: fs_ofdcustomtag.h:105
字体资源类型。
Definition: fs_ofddoc.h:318
Definition: fs_ofdpermission.h:17
ofdseal::Signature GetSignature(int index)
获取签名或签章对象。
WString GetMultiMediaFileNameByID(foxit::uint32 res_id)
获取多媒体文件名。
Definition: fs_ofdsignature.h:209
void EndTagTreeNode(const String &key_path)
结束添加票据标引节点。
CustomTags CreateCustomTags()
创建自定义标签。
绘制参数资源类型。
Definition: fs_ofddoc.h:316
EncryptMethod
OFD文档加密方法枚举类型。
Definition: fs_ofddoc.h:278
OFDPage GetPageByID(foxit::uint32 id)
获取OFD页面。
void RemoveKeyword(int index)
删除指定关键字。
OFDPermission CreatePermissions()
创建权限对象。
foxit::common::file::ReaderCallback * GetMultiMediaFileByID(int res_id)
通过资源ID获取多媒体文件指针。
OFDTemplatePage AddTemplatePageFromPage(OFDPage page)
添加新的模板页面。
WString GetMultiMediaTypeByID(foxit::uint32 res_id)
获取多媒体类型。
Definition: fs_ofdcatalog.h:19
Bookmarks GetBookmarks()
获取书签。
void SetMetadata(const WString &key, const WString &value)
设置OFD Metadata项。
多媒体资源类型。
Definition: fs_ofddoc.h:320
bool AddCatalog(const Catalog &catalog)
添加目录。
bool SaveXmlFileAttachment(int index, const String &file_path)
保存XML附件到文件中。
void RemovePage(int index)
删除指定的OFD页面。
float font_size
页码文本字体大小。这应该是一个正值,默认为12。
Definition: fs_ofddoc.h:224
WString font_name
页码文本字体名字。
Definition: fs_ofddoc.h:219
void InitializeTagTreeNode(const String &type, const String &name_space, const String &name, const String &file_extension, bool key_unique)
在文档中初始化指定类型的票据标引树根节点。
加密类型:AES128。
Definition: fs_ofddoc.h:298
bool RemoveEncryption(const String &owner_password)
移除文档加密。
PageNumberParameter()
构造函数。
Definition: fs_ofddoc.h:79
EncryptType
OFD文档加密类型枚举类型。
Definition: fs_ofddoc.h:292
bool RestoreOriginalDocument()
恢复到原始文档。
int first_page_number
起始页码的数值,默认为1。
Definition: fs_ofddoc.h:249
颜色空间资源类型。
Definition: fs_ofddoc.h:314
FX_UINT32 uint32
无符号 32 位整数。
Definition: fs_basictypes.h:195
边距正常。
Definition: fs_ofddoc.h:70
TagTreeNode GetTagTreeRoot(const String &type)
获取指定类型的票据标引树根节点。
int end_page
终止页面,有效范围:从1到(count)。count 由函数 OFDPagckage::GetDocumentCount 返回。
Definition: fs_ofddoc.h:239
void * FS_HANDLE
句柄类型。
Definition: fs_basictypes.h:213
通用定义和类的头文件。
void ClearTagTreeNode()
清除票据标引所有节点。
bool InsertDocument(const OFDDoc &other, int dest_index=-1)
插入新的文档。
Definition: fs_ofdpage.h:415
void InitializeCertTagTreeNode(bool key_unique)
在文档中初始化电子证照标引树根节点。
Definition: fs_ofddoc.h:271
void ExportAnnots(const String &file_path)
导出注释。
OFDPage InsertPage(int index)
插入新的OFD页面。
String GetMultiMediaBufferByID(foxit::uint32 res_id)
获取多媒体内存缓冲区。
Definition: fs_basictypes.h:465
复合图形单元资源类型。
Definition: fs_ofddoc.h:322
int GetAttachmentCount()
获取OFD附件数量
void EmbedFont(const String &font_name)
内嵌字体。
foxit::uint32 AddFontResourceFromName(const String &font_family, const String &font_name)
添加字体资源到OFD文档。
Type
图像类型的枚举。
Definition: fs_image.h:457
PageNumberMarginType margin
页码位置类型。
Definition: fs_ofddoc.h:262
OFDTemplatePage GetTemplatePage(int index)
获取OFD模板页面。
void AddPageNumber(const PageNumberParameter &param)
根据页码参数添加页码。
加密类型:AES256。
Definition: fs_ofddoc.h:300
加密方法:密码加密
Definition: fs_ofddoc.h:282
Foxit命名空间。
Definition: fs_taggedpdf.h:27
Definition: fs_ofddoc.h:39
bool skip_blank_page
是否跳过空白页。true代表跳过空白页,false代表不跳过空白页。
Definition: fs_ofddoc.h:267
字节字符串类
Definition: fx_string.h:317
bool RefreshObjectsPermission(bool authenticated)
刷新文档所有对象权限。
int GetXmlFileAttachmentCount()
获取OFD XML附件数量
Definition: fs_ofdpage.h:27
int start_page
起始页面,有效范围:从1到(count)。count 由函数 OFDPagckage::GetDocumentCount 返回。
Definition: fs_ofddoc.h:234
int GetSignatureCount()
获取签名和签章数量。
Outline GetOutline()
获取大纲。
OFDPage AddPage()
添加新的页面。
#define NULL
空指针值。
Definition: fx_system.h:792
WString GetCustomDataName(int index)
获取OFD自定义数据。
foxit::uint32 AddImageResourceFromFile(const String &file_path)
从图片文件添加资源到OFD文档。
void RemoveTemplatePage(int index)
删除模板页面。
void InsertKeyword(const WString &keyword, int index=-1)
插入关键字到OFD Metadata项。
加密方法:无。
Definition: fs_ofddoc.h:280
PageNumberParameter(PageNumberLocationType location, const WString &font_name, float font_size, foxit::RGB text_color, int start_page, int end_page, bool is_first_page_cover, int first_page_number, bool is_folio, PageNumberMarginType margin, bool skip_blank_page)
带参数的构造函数。
Definition: fs_ofddoc.h:115
foxit::uint32 AddImageResourceFromBuffer(const String &buffer, foxit::common::Image::Type format)
从图片文件添加资源到OFD文档。
加密类型:SM4。
Definition: fs_ofddoc.h:302
未知类型。
Definition: fs_ofddoc.h:312
Definition: fs_flddoc.h:25
PageNumberLocationType location
页码位置类型。
Definition: fs_ofddoc.h:214
void ExportMultiMediaByID(foxit::uint32 res_id, const String &file_path)
保存多媒体文件。
Bookmarks CreateBookmarks()
创建书签。
bool operator==(const OFDDoc &other) const
相等操作符。
PageNumberLocationType
OFD添加页码位置枚举类型。
Definition: fs_ofddoc.h:46
OFDDoc(const foxit::fld::FLDDoc &doc)
构造函数,从现有foxit::fld::FLDDoc对象。
OFDTemplatePage GetTemplatePageByName(const String &name)
获取OFD模板页面。