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 
216 
221 
225  float font_size;
226 
231 
237 
242  int end_page;
243 
249 
254 
259  bool is_folio;
260 
269 
275 };
276 
278 class OFDDoc FS_FINAL : public Base {
279  public:
285  typedef enum _EncryptMethod {
292  } EncryptMethod;
293 
299  typedef enum _EncryptType {
310  } EncryptType;
311 
317  typedef enum _ResourceType {
330  } ResourceType;
331 
332 
338  explicit OFDDoc(const foxit::fld::FLDDoc& doc);
339 
341  ~OFDDoc();
342 
348  OFDDoc(const OFDDoc& other);
349 
357  OFDDoc& operator = (const OFDDoc& other);
358 
366  bool operator == (const OFDDoc& other) const;
367 
375  bool operator != (const OFDDoc& other) const;
376 
384  bool IsEmpty() const;
385 
391  int GetPageCount();
392 
401  OFDPage GetPage(int index);
402 
411 
417  OFDPage AddPage();
418 
427  OFDPage InsertPage(int index);
428 
437  void RemovePage(int index);
438 
447  void ReservedPage(int index);
448 
459  bool MovePage(int index, int dest_index);
460 
466  int GetTemplatePageCount();
467 
476  OFDTemplatePage GetTemplatePage(int index);
477 
486 
495 
505 
514  void RemoveTemplatePage(int index);
515 
521  void RemoveAllTemplatePages();
522 
529 
538 
550  OFDPage AddPageFromTemplatePage(int index, int dest_index = -1);
551 
558 
565 
571  int GetAttachmentCount();
572 
581  Attachment GetAttachment(int index);
582 
591 
600  String GetAttachmentBuffer(int index);
601 
611 
621  void ExportAttachment(int index, const String& file_path);
622 
632  void ExportAttachment(int index, const WString& file_path);
633 
643  void ExportAttachment(int index, foxit::common::file::WriterCallback* file_writer);
644 
654  Attachment AddAttachment(const String& file_name, const String& name = NULL, const String& usage = NULL);
655 
665  Attachment AddAttachment(const WString& file_name, const String& name = NULL, const String& usage = NULL);
666 
673 
683  bool SaveXmlFileAttachment(int index, const String& file_path);
684 
694  bool SaveXmlFileAttachment(int index, const WString& file_path);
695 
703  WString GetMetadata(const WString& key);
704 
713  void SetMetadata(const WString& key, const WString& value);
714 
720  int GetKeywordCount();
721 
730  void InsertKeyword(const WString& keyword, int index = -1);
731 
740  void RemoveKeyword(int index);
741 
747  int GetCustomDataCount();
748 
757  WString GetCustomDataName(int index);
758 
767  WString GetCustomDataValue(int index);
768 
777  void AddCustomData(const String& key, const String& value);
778 
788  void InsertCustomData(const String& key, const String& value, int index);
789 
798  void RemoveCustomData(int index);
799 
807  foxit::uint32 AddResourceFromFile(const String& file_path, const String& format);
808 
817  foxit::uint32 AddResourceFromFile(const WString& file_path, const String& format);
818 
827 
836 
848 
857  foxit::uint32 AddFontResourceFromName(const String& font_family, const String& font_name);
858 
868 
877 
886  void ExportMultiMediaByID(foxit::uint32 res_id, const String& file_path);
887 
896  void ExportMultiMediaByID(foxit::uint32 res_id, const WString& file_path);
897 
907 
916 
925 
934 
943 
951  void ExportAnnots(const String& file_path);
952 
964  void ExportAnnots(int start_index, int end_index, const String& file_path);
965 
973  void ImportAnnots(const String& file_path);
974 
982  void AddPageNumber(const PageNumberParameter& param);
983 
993  bool InsertDocument(const OFDDoc& other, int dest_index = -1);
994 
1001 
1007  Outline GetOutline();
1008 
1014  bool RemoveOutline();
1015 
1023  bool AddCatalog(const Catalog& catalog);
1024 
1030  int GetSignatureCount();
1031 
1040  ofdseal::Signature GetSignature(int index);
1041 
1048 
1055 
1062 
1069 
1077  TagTreeNode GetTagTreeRoot(const String& type);
1078 
1090  void InitializeTagTreeNode(const String& type, const String& name_space, const String& name, const String& file_extension, bool key_unique);
1091 
1099  void InitializeCertTagTreeNode(bool key_unique);
1100 
1108  void BeginTagTreeNode(const String& key_path);
1109 
1118  void AddTagTreeNodeMetaData(const String& key, const String& value);
1119 
1127  void EndTagTreeNode(const String& key_path);
1128 
1134  void ClearTagTreeNode();
1135 
1143  bool ExportOfficeDoc(const String& file_path);
1144 
1152  bool ExportOfficeDoc(const WString& file_path);
1153 
1159  bool RestoreOriginalDocument();
1160 
1168  bool RefreshObjectsPermission(bool authenticated);
1169 
1177  bool RemoveEncryption(const String& owner_password);
1178 
1185 
1192 
1201  void EmbedFont(const String& font_name);
1202 
1208  int GetVersionCount();
1209 
1218  void SetCurrentVersion(int index);
1219 
1225  void CreateVersion();
1226 
1227  explicit OFDDoc(FS_HANDLE handle = NULL);
1228 };
1229 
1230 } // namespace ofd
1231 } // namespace foxit
1232 
1233 #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
CFX_Object Object
对象类型。
Definition: fs_basictypes.h:220
foxit::RGB text_color
页码文本颜色。默认为黑色。
Definition: fs_ofddoc.h:230
OFDTemplatePage AddTemplatePage()
添加新的模板页面。
PageNumberParameter & operator=(const PageNumberParameter &other)
赋值操作符。
Definition: fs_ofddoc.h:155
加密类型:RC4。
Definition: fs_ofddoc.h:303
bool operator !=(const OFDDoc &other) const
不相等操作符。
foxit::common::file::ReaderCallback * GetAttachmentFile(int index)
获取OFD附件文件指针。
bool is_folio
是否为对开页面,true代表是对开页面,false代表不是。 默认为不是对开页面。
Definition: fs_ofddoc.h:259
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:248
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:301
ResourceType
OFD资源类型枚举类型。
Definition: fs_ofddoc.h:317
加密方法:证书加密
Definition: fs_ofddoc.h:291
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:325
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:323
EncryptMethod
OFD文档加密方法枚举类型。
Definition: fs_ofddoc.h:285
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:327
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:225
WString font_name
页码文本字体名称。默认为"宋体"。
Definition: fs_ofddoc.h:220
void InitializeTagTreeNode(const String &type, const String &name_space, const String &name, const String &file_extension, bool key_unique)
在文档中初始化指定类型的票据标引树根节点。
加密类型:AES128。
Definition: fs_ofddoc.h:305
bool RemoveEncryption(const String &owner_password)
移除文档加密。
PageNumberParameter()
构造函数。
Definition: fs_ofddoc.h:79
EncryptType
OFD文档加密类型枚举类型。
Definition: fs_ofddoc.h:299
bool RestoreOriginalDocument()
将安全语义删除,恢复到原始文档。存在安全语义时此函数才会执行恢复操作,否则什么都不会发生。
int first_page_number
起始页码的数值,默认为1。
Definition: fs_ofddoc.h:253
颜色空间资源类型。
Definition: fs_ofddoc.h:321
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 返回。 默认为0。
Definition: fs_ofddoc.h:242
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:278
void ExportAnnots(const String &file_path)
导出注释。
OFDPage InsertPage(int index)
插入新的OFD页面。
String GetMultiMediaBufferByID(foxit::uint32 res_id)
获取多媒体内存缓冲区。
Definition: fs_basictypes.h:471
复合图形单元资源类型。
Definition: fs_ofddoc.h:329
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:458
PageNumberMarginType margin
页码位置类型。
Definition: fs_ofddoc.h:268
OFDTemplatePage GetTemplatePage(int index)
获取OFD模板页面。
void AddPageNumber(const PageNumberParameter &param)
根据页码参数添加页码。
加密类型:AES256。
Definition: fs_ofddoc.h:307
加密方法:密码加密
Definition: fs_ofddoc.h:289
Foxit命名空间。
Definition: fs_pdf3d.h:26
Definition: fs_ofddoc.h:39
bool skip_blank_page
是否跳过空白页。true代表跳过空白页,false代表不跳过空白页。 默认为不跳过空白页。
Definition: fs_ofddoc.h:274
字节字符串类
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 返回。 默认为0。
Definition: fs_ofddoc.h:236
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:287
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:309
未知类型。
Definition: fs_ofddoc.h:319
Definition: fs_flddoc.h:25
PageNumberLocationType location
页码位置类型。
Definition: fs_ofddoc.h:215
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模板页面。