ArkoPDF
← SDK-API-Referenz

ipdf_document.h

文档对象:打开/关闭 PDF、页面访问、字体管理、加密与文档元信息。

Die Schnittstellenbeschreibungen bleiben im englischen Original der Header — so lassen sie sich direkt mit dem Code abgleichen.

Konstanten

SignaturValueDescription
PDF_OPEN_ERROR_SUCCESS0no error.
PDF_OPEN_ERROR_FILE1file error: not found or could not be opened.
PDF_OPEN_ERROR_FORMAT2format error: not a PDF or corrupted.
PDF_OPEN_ERROR_PASSWORD3Invalid password. Need input again.
PDF_OPEN_ERROR_HANDLER4This document is encrypted by some unsupported security handler.
PDF_OPEN_ERROR_CERT5This document is encrypted by digital certificate and current user doesn't have correct certificate.
USER_PERM_PRINT0x0004—
USER_PERM_MODIFY0x0008—
USER_PERM_EXTRACT0x0010—
USER_PERM_ANNOT_FORM0x0020—
USER_PERM_FILL_FORM0x0100—
USER_PERM_EXTRACT_ACCESS0x0200—
USER_PERM_ASSEMBLE0x0400—
USER_PERM_PRINT_HIGH0x0800—
ENCRYPT_CIPHER_NONE0—
ENCRYPT_CIPHER_RC41—
ENCRYPT_CIPHER_AES2—
ENCRYPT_CIPHER_AES23—
PDF_ENCODING_BUILTIN0Built-in encoding.
PDF_ENCODING_WINANSI1WinAnsiEncoding.
PDF_ENCODING_MACROMAN2MacRomanEncoding.
PDF_ENCODING_MACEXPERT3MacExpertEncoding.
PDF_ENCODING_STANDARD4StandardEncoding. Adobe standard encoding.
PDF_ENCODING_ADOBE_SYMBOL5Adobe symbol encoding.
PDF_ENCODING_ZAPFDINGBATS6ZapfDingbats encoding.
PDF_ENCODING_PDFDOC7PDFDocEncoding.
PDF_ENCODING_MS_SYMBOL8Microsoft symbol encoding.
PDF_ENCODING_UNICODE9Unicode.
PDF_CREATE_INCREMENTAL1Incremental.
PDF_CREATE_NO_ORIGINAL2No original.
PDF_CREATE_PROGRESSIVE4Use progressive creator.
PDF_CREATE_OBJECTSTREAM8Use object stream creator.

class IPDF_Document

Interfac for a PDF document.

Methoden(44)

SignaturBeschreibung
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.

Parameter

  • page_width(in) — The blank page width.
  • page_height(in) — The blank page height.
  • nBlankPages(in) — The total number of new black pages.

Rückgabewert:1 for success, 0 for failur.

Open
int Open(void* data, unsigned int data_len) = 0;

Open a PDF document in memeroy.

Parameter

  • data(in) — The PDF memeroy data.
  • data_len(in) — The length of data.

Rückgabewert: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.

Parameter

  • bReParse(in) — Whether reparsing is used.
InputPassword
void InputPassword(const char* password) = 0;

Set the password of standard encryption for opennig document.

Parameter

  • 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.

Parameter

  • page_index(in) — Specifies the zero-based index of the page in the document.

Rückgabewert: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.

Parameter

  • 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.

Parameter

  • page_handler(in) — The page handler.
CountExistFonts
int CountExistFonts() = 0;

Count the font number in the document.

Rückgabewert: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.

Parameter

  • 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 IDs
  • code_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.

Parameter

  • face_name(in) — The font name.
  • encoding(in) — Predefined font encoding.@see Predefined font encoding

Rückgabewert: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.

Parameter

  • font_file(in) — The font file path.
  • charset(in) — Charset ID.@see Font charsets
  • isVertical(in) — Whether it's a vertical writing font. For CJK charsets only.

Rückgabewert: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.

Parameter

  • font_file(in) — The font file path (utf8).
  • charset(in) — Charset ID.@see Font charsets
  • isVertical(in) — Whether it's a vertical writing font. For CJK charsets only.

Rückgabewert:A PDF font.

AddWinFont
IPDF_Font* AddWinFont(LOGFONTW* pLogFont, int bVert = 0, int bTranslateName = 0) = 0;

Import a Windows font.

Parameter

  • 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.

Rückgabewert:A PDF font.

AddFolderFont
IPDF_Font* AddFolderFont(IPDF_FolderFontInfo* pFontInfo, int charset) = 0;

Import a folder font on Android.

Parameter

  • pFontInfo(in) — Points to a IPDF_FolderFontInfo handler.
  • charset(in) — Charset ID.@see Font charsets

Rückgabewert:A PDF font.

AddFontByFaceName
IPDF_Font* AddFontByFaceName(const char* face_name, int charset, int isVertical = 0) = 0;

Import a font by spcificed font information.

Parameter

  • face_name(in) — The font face name.
  • charset(in) — Charset ID.@see Font charsets
  • bVert(in) — Vertical font or not.

Rückgabewert: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.

Parameter

  • password(in) — The input password pointer.
  • pass_len(in) — The length of the password.
  • bOwner(in) — Whether check the owner password

Rückgabewert:0 for invalid password, 1 for password verified.

SetTitle
void SetTitle(const char* title) = 0;

Set new document title.

Parameter

  • title(in) — The new title.
SetAuthor
void SetAuthor(const char* author) = 0;

Set new document author.

Parameter

  • author(in) — The new author.
SetCreator
void SetCreator(const char* creator) = 0;

Set new document creator.

Parameter

  • creator(in) — The new creator.
SetCreationDate
void SetCreationDate(const char* date) = 0;

Set creation date.

Parameter

  • date(in) — The new date.
SetModifyDate
void SetModifyDate(const char* date) = 0;

Set last modified date.

Parameter

  • date(in) — The new date.
SetSubject
void SetSubject(const char* subject) = 0;

Set new document subject.

Parameter

  • subject(in) — The new subject.
IsXRefStream
int IsXRefStream() = 0;

Whether cross reference stream is used.

Rückgabewert: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.

Rückgabewert:The number of named destination.

GetNamedDestName
const char* GetNamedDestName(int index) = 0;

Get name of spcificed named destination.

Parameter

  • index(in) — Zero based index, range is 0 to CountNamedDests().

Rückgabewert:The destination name.

class IPDF_Creator

PDF Creator Interface

Methoden(7)

SignaturBeschreibung
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.

Parameter

  • 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).

Parameter

  • dest_file(in) — The output filename(The length must less than 256).
  • pause(in) — Pause object, optional.
  • pProgress(in) — Progress object, optional.

Rückgabewert: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.

Parameter

  • 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)

Parameter

  • 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.

Rückgabewert:1 for success, 0 for failur.

RemoveSecurity
int RemoveSecurity() = 0;

Remove security settings with document. The output file will not be encrypted.

Rückgabewert:1 for success, 0 for failur.