ipdf_document.h
文档对象:打开/关闭 PDF、页面访问、字体管理、加密与文档元信息。
インターフェースの説明はヘッダーの英語原文のままにしています。読んでいるコードと突き合わせやすくするためです。
定数
| シグネチャ | Value | Description |
|---|---|---|
| PDF_OPEN_ERROR_SUCCESS | 0 | no error. |
| PDF_OPEN_ERROR_FILE | 1 | file error: not found or could not be opened. |
| PDF_OPEN_ERROR_FORMAT | 2 | format error: not a PDF or corrupted. |
| PDF_OPEN_ERROR_PASSWORD | 3 | Invalid password. Need input again. |
| PDF_OPEN_ERROR_HANDLER | 4 | This document is encrypted by some unsupported security handler. |
| PDF_OPEN_ERROR_CERT | 5 | This document is encrypted by digital certificate and current user doesn't have correct certificate. |
| USER_PERM_PRINT | 0x0004 | — |
| USER_PERM_MODIFY | 0x0008 | — |
| USER_PERM_EXTRACT | 0x0010 | — |
| USER_PERM_ANNOT_FORM | 0x0020 | — |
| USER_PERM_FILL_FORM | 0x0100 | — |
| USER_PERM_EXTRACT_ACCESS | 0x0200 | — |
| USER_PERM_ASSEMBLE | 0x0400 | — |
| USER_PERM_PRINT_HIGH | 0x0800 | — |
| ENCRYPT_CIPHER_NONE | 0 | — |
| ENCRYPT_CIPHER_RC4 | 1 | — |
| ENCRYPT_CIPHER_AES | 2 | — |
| ENCRYPT_CIPHER_AES2 | 3 | — |
| PDF_ENCODING_BUILTIN | 0 | Built-in encoding. |
| PDF_ENCODING_WINANSI | 1 | WinAnsiEncoding. |
| PDF_ENCODING_MACROMAN | 2 | MacRomanEncoding. |
| PDF_ENCODING_MACEXPERT | 3 | MacExpertEncoding. |
| PDF_ENCODING_STANDARD | 4 | StandardEncoding. Adobe standard encoding. |
| PDF_ENCODING_ADOBE_SYMBOL | 5 | Adobe symbol encoding. |
| PDF_ENCODING_ZAPFDINGBATS | 6 | ZapfDingbats encoding. |
| PDF_ENCODING_PDFDOC | 7 | PDFDocEncoding. |
| PDF_ENCODING_MS_SYMBOL | 8 | Microsoft symbol encoding. |
| PDF_ENCODING_UNICODE | 9 | Unicode. |
| PDF_CREATE_INCREMENTAL | 1 | Incremental. |
| PDF_CREATE_NO_ORIGINAL | 2 | No original. |
| PDF_CREATE_PROGRESSIVE | 4 | Use progressive creator. |
| PDF_CREATE_OBJECTSTREAM | 8 | Use object stream creator. |
class IPDF_Document
Interfac for a PDF document.
メソッド(44)
| シグネチャ | 説明 |
|---|---|
| NewBlankDoc(float page_width, float page_height, int nBlankPages = 1) | Create a new document with a blank page. |
| Open(void* data, unsigned int data_len) | Open a PDF document in memeroy. |
| Close(int bReParse = 0) | Close the documet, as well as the file. If reparsing is used, the document will be kept. |
| InputPassword(const char* password) | Set the password of standard encryption for opennig document. |
| GetPageCount() | Get number of pages in this document. |
| GetPage(int page_index) | Get page object of a specified page index. Page index starts from zero for the first page. |
| GetPageSizeQuickly(int page_count, float* page_width_array, float* page_height_…) | Enumerate page size in the document. |
| GetPageByHandler(PDF_PageHandler page_handler) | Get page object of a specified page handler. Page handler is a pointer which point to a page dictionary. |
| CountExistFonts() | Count the font number in the document. |
| GetExistFontInfo(int index, wchar_t facename[32], int* isEmbbed, int* type, i…) | Get a exist font information. |
| AddStdFont(const char* face_name, int encoding) | Add a Type1 base-14 font. |
| AddFont(const wchar_t* font_file, int charset, int isVertical = 0) | Add a new font by specificed font file. |
| AddFont(const char* font_file_utf8, int charset, int isVertical = 0) | Add a new font by specificed font file. |
| AddWinFont(LOGFONTW* pLogFont, int bVert = 0, int bTranslateName = 0) | Import a Windows font. |
| AddWinFont(LOGFONTA* pLogFont, int bVert = 0, int bTranslateName = 0) | — |
| AddMacFont(CTFontRef pFont, int bVert, int bTranslateName = 0, int char…) | — |
| AddFolderFont(IPDF_FolderFontInfo* pFontInfo, int charset) | Import a folder font on Android. |
| AddFontByFaceName(const char* face_name, int charset, int isVertical = 0) | Import a font by spcificed font information. |
| IsOwner() | Whether the user has the owner permission of the document. |
| GetPermission() | Get the user permissions. |
| IsEncrypted() | Test whether the document is encrypted, 0 for not, 1 for encrypted |
| GetEncryptFilterType() | Get encryptor filter type |
| CheckPassword(const char* password, int pass_len, int bOwner) | Check whether the password is verified successfully. |
| GetCryptInfo(int& cipher, const unsigned char*& buffer, int& keylen) | — |
| IsMetaDataEncrypted() | — |
| GetPageOrganizer() | Get the Page Organizer interfance |
| GetPageDesigner() | Get the Page Designer interfance |
| GetBookmarks() | Get the Bookmark Tree interfance |
| GetTitle() | Get title |
| GetAuthor() | Get author |
| GetCreator() | Get creator |
| GetCreationDate() | Get creation date |
| GetModifyDate() | Gee last modified date |
| GetSubject() | Get subject |
| GetProductor() | Get productor |
| SetTitle(const char* title) | Set new document title. |
| SetAuthor(const char* author) | Set new document author. |
| SetCreator(const char* creator) | Set new document creator. |
| SetCreationDate(const char* date) | Set creation date. |
| SetModifyDate(const char* date) | Set last modified date. |
| SetSubject(const char* subject) | Set new document subject. |
| IsXRefStream() | Whether cross reference stream is used. |
| CountNamedDests() | Count the total number of named destination in the document. |
| GetNamedDestName(int index) | Get name of spcificed named destination. |
NewBlankDoc
public: virtual int NewBlankDoc(float page_width, float page_height, int nBlankPages = 1) = 0;
Create a new document with a blank page.
パラメータ
page_width(in) — The blank page width.page_height(in) — The blank page height.nBlankPages(in) — The total number of new black pages.
戻り値:1 for success, 0 for failur.
Open
int Open(void* data, unsigned int data_len) = 0;
Open a PDF document in memeroy.
パラメータ
data(in) — The PDF memeroy data.data_len(in) — The length of data.
戻り値:The status of PDF parsing.
见 Reasons for PDF opening failure
Close
void Close(int bReParse = 0) = 0;
Close the documet, as well as the file. If reparsing is used, the document will be kept.
パラメータ
bReParse(in) — Whether reparsing is used.
InputPassword
void InputPassword(const char* password) = 0;
Set the password of standard encryption for opennig document.
パラメータ
password(in) — The input password.
GetPage
IPDF_Page* GetPage(int page_index) = 0;
Get page object of a specified page index. Page index starts from zero for the first page.
パラメータ
page_index(in) — Specifies the zero-based index of the page in the document.
戻り値:The specified page object.
GetPageSizeQuickly
void GetPageSizeQuickly(int page_count, float* page_width_array, float* page_height_array) = 0;
Enumerate page size in the document.
パラメータ
page_count(in) — The page count.page_width_array(out) — Page width array to receiv the page width.page_height_array(out) — Page height array to receiv the page heigt..
GetPageByHandler
IPDF_Page* GetPageByHandler(PDF_PageHandler page_handler) = 0;
Get page object of a specified page handler. Page handler is a pointer which point to a page dictionary.
パラメータ
page_handler(in) — The page handler.
CountExistFonts
int CountExistFonts() = 0;
Count the font number in the document.
戻り値:The total font number.
GetExistFontInfo
void GetExistFontInfo(int index, wchar_t facename[32], int* isEmbbed, int* type, int* code_type, wchar_t basefont[32], int* base_type) = 0;
Get a exist font information.
パラメータ
index(in) — The font index (0 to CountExistFonts()).facename(out) — A buffer to receiv the font face name.isEmbbed(out) — A flag indicate whether font is embbedded in the doucument.type(out) — Font type flag.@see Font type IDscode_type(out) — Encodding type.basefont(out) — Base font name.base(out) — type Base font type.@see Font type IDs
AddStdFont
IPDF_Font* AddStdFont(const char* face_name, int encoding) = 0;
Add a Type1 base-14 font.
パラメータ
face_name(in) — The font name.encoding(in) — Predefined font encoding.@see Predefined font encoding
戻り値:A PDF font.
AddFont
IPDF_Font* AddFont(const wchar_t* font_file, int charset, int isVertical = 0) = 0;
Add a new font by specificed font file.
パラメータ
font_file(in) — The font file path.charset(in) — Charset ID.@see Font charsetsisVertical(in) — Whether it's a vertical writing font. For CJK charsets only.
戻り値:A PDF font.
AddFont
IPDF_Font* AddFont(const char* font_file_utf8, int charset, int isVertical = 0) = 0;
Add a new font by specificed font file.
パラメータ
font_file(in) — The font file path (utf8).charset(in) — Charset ID.@see Font charsetsisVertical(in) — Whether it's a vertical writing font. For CJK charsets only.
戻り値:A PDF font.
AddWinFont
IPDF_Font* AddWinFont(LOGFONTW* pLogFont, int bVert = 0, int bTranslateName = 0) = 0;
Import a Windows font.
パラメータ
pLogFont(in) — Points to a LOGFONT(WIN32) structure.bVert(in) — Vertical font or not.bTranslateName(in) — Whether we will do font name translating or not.
戻り値:A PDF font.
AddFolderFont
IPDF_Font* AddFolderFont(IPDF_FolderFontInfo* pFontInfo, int charset) = 0;
Import a folder font on Android.
パラメータ
pFontInfo(in) — Points to a IPDF_FolderFontInfo handler.charset(in) — Charset ID.@see Font charsets
戻り値:A PDF font.
AddFontByFaceName
IPDF_Font* AddFontByFaceName(const char* face_name, int charset, int isVertical = 0) = 0;
Import a font by spcificed font information.
パラメータ
face_name(in) — The font face name.charset(in) — Charset ID.@see Font charsetsbVert(in) — Vertical font or not.
戻り値:A PDF font. NOTE:Face name can be following: DengXian, DengXian Bold, DengXian Italic, DengXian Light, Microsoft YaHei, Microsoft YaHei UI,Microsoft YaHei Negreta, Microsoft YaHei UI Negreta,Microsoft YaHei UI Light, FangSong,SimHei,KaiTi, LiSu,SimSun,NSimSun,YouYuan
CheckPassword
int CheckPassword(const char* password, int pass_len, int bOwner) = 0;
Check whether the password is verified successfully.
パラメータ
password(in) — The input password pointer.pass_len(in) — The length of the password.bOwner(in) — Whether check the owner password
戻り値:0 for invalid password, 1 for password verified.
SetTitle
void SetTitle(const char* title) = 0;
Set new document title.
パラメータ
title(in) — The new title.
SetAuthor
void SetAuthor(const char* author) = 0;
Set new document author.
パラメータ
author(in) — The new author.
SetCreator
void SetCreator(const char* creator) = 0;
Set new document creator.
パラメータ
creator(in) — The new creator.
SetCreationDate
void SetCreationDate(const char* date) = 0;
Set creation date.
パラメータ
date(in) — The new date.
SetModifyDate
void SetModifyDate(const char* date) = 0;
Set last modified date.
パラメータ
date(in) — The new date.
SetSubject
void SetSubject(const char* subject) = 0;
Set new document subject.
パラメータ
subject(in) — The new subject.
IsXRefStream
int IsXRefStream() = 0;
Whether cross reference stream is used.
戻り値:0 for no XRef stream used, 1 for XRef stream used.
CountNamedDests
int CountNamedDests() = 0;
Count the total number of named destination in the document.
戻り値:The number of named destination.
GetNamedDestName
const char* GetNamedDestName(int index) = 0;
Get name of spcificed named destination.
パラメータ
index(in) — Zero based index, range is 0 to CountNamedDests().
戻り値:The destination name.
class IPDF_Creator
PDF Creator Interface
メソッド(7)
| シグネチャ | 説明 |
|---|---|
| Release() | Release a creator |
| Init(IPDF_Document* doc, int flags) | Initial a crator. |
| Create(const wchar_t* dest_file, IPDF_Pause* pause, IPDF_Progress* …) | Write the whole document into a new file (using local file name). |
| Create(const char* dest_file_utf8, IPDF_Pause* pause, IPDF_Progress…) | — |
| SetSecurity(unsigned int permissions, const char* owner_pwd, const char*…) | Set security settings using standard security handler only. |
| UpdateSecurity(unsigned int permissions, const char* owner_pwd, const char*…) | Update security permissions for Revision 5 and 6 handler (AES 256) |
| RemoveSecurity() | Remove security settings with document. The output file will not be encrypted. |
Init
void Init(IPDF_Document* doc, int flags) = 0;
Initial a crator.
パラメータ
doc(in) — The PDF document.flags(in) — The creating flags.@see Creating flags for PDF creator
Create
int Create(const wchar_t* dest_file, IPDF_Pause* pause, IPDF_Progress* pProgress) = 0;
Write the whole document into a new file (using local file name).
パラメータ
dest_file(in) — The output filename(The length must less than 256).pause(in) — Pause object, optional.pProgress(in) — Progress object, optional.
戻り値:Non-zero means success, otherwise failed.
SetSecurity
int SetSecurity(unsigned int permissions, const char* owner_pwd, const char* user_pwd, int cipher, int keylen, int isEncryptMetaData) = 0;
Set security settings using standard security handler only.
パラメータ
permissions(in) — The user permissions.owner_pwd(in) — The owner password.user_pwd(in) — The user password.cipher(in) — The cipher type, RC4 or AES.keylen(in) — The length of the document key.isEncryptMetaData(in) — Whether to encrypt the metadata.
UpdateSecurity
int UpdateSecurity(unsigned int permissions, const char* owner_pwd, const char* user_pwd, int cipher, int keylen, int isEncryptMetaData) = 0;
Update security permissions for Revision 5 and 6 handler (AES 256)
パラメータ
permissions(in) — New permissions value.owner_pwd(in) — The owner password pointer.user_pwd(in) — The user password pointer.cipher(in) — The cipher type, RC4 or AES.keylen(in) — The length of the document key.bEncryptMetadata(in) — New EncryptMetadata value.
戻り値:1 for success, 0 for failur.
RemoveSecurity
int RemoveSecurity() = 0;
Remove security settings with document. The output file will not be encrypted.
戻り値:1 for success, 0 for failur.