diff --git a/CMakeLists.txt b/CMakeLists.txt index 86b2b5d..188322f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -106,16 +106,16 @@ if (MSVC) endforeach(file_i) else () - message(warning "build/Debug must be created before running, otherwise an error will be thrown.") - find_path(PODOFO_INCLUDE_DIR podofo/podofo.h PATHS /usr/include /usr/local/include) - find_library(PODOFO_LIBRARY NAMES podofo PATHS /usr/lib64 /usr/lib /usr/local/lib) + message(warning "Creating build output directory: build/${CMAKE_BUILD_TYPE}") + file(MAKE_DIRECTORY ${CMAKE_SOURCE_DIR}/build/${CMAKE_BUILD_TYPE}) + find_path(PODOFO_INCLUDE_DIR podofo/podofo.h PATHS /sources/local /usr/include /usr/local/include) + find_library(PODOFO_LIBRARY NAMES podofo PATHS /sources/local /usr/lib64 /usr/lib /usr/local/lib) target_include_directories(${PROJECT_NAME} PRIVATE ${PODOFO_INCLUDE_DIR}) target_link_libraries(${PROJECT_NAME} PRIVATE ${PODOFO_LIBRARY}) add_custom_command(TARGET nopodofo POST_BUILD COMMAND "${CMAKE_COMMAND}" -E copy $ ${CMAKE_SOURCE_DIR}/build/${CMAKE_BUILD_TYPE}) - endif (MSVC) diff --git a/docs/dictionary.md b/docs/dictionary.md index f2dff64..ab54107 100644 --- a/docs/dictionary.md +++ b/docs/dictionary.md @@ -14,14 +14,16 @@ * [writeSync](#writesync) ## NoPoDoFo Dictionary - +A Dictionary is one of the primary building blocks of a PDF. The PDF dictionary type data structure is similar to a nodejs object data structure in +that it is simply a collection of key value pairs. NoPoDoFo does not support the creation of new Dictionary objects, actions that require creating +a new Dictionary are handled implicitly by PoDoFo. ```typescript class Dictionary { dirty: boolean immutable: boolean - getKey(k: string): Object - addKey(prop: string, value: boolean | number | string | Object): void + getKey(k: string): nopodofo.Object + addKey(prop: NPDFName|string, value: boolean | number | string | nopodofo.Object): void getKeys(): string[] hasKey(k: string): boolean removeKey(k: string): void @@ -32,6 +34,42 @@ class Dictionary { } ``` +## Properties + +### dirty +This flag is internally by PoDoFo, dirty is set to true if there has been a modification after construction. + +### immutable +This property will get or set a corresponding property on the PoDoFo PdfDictionary. When set to true no keys can be edited or changed. + ## Methods -## Properties \ No newline at end of file +### getKey +Get the value of the `k` key. Value is returned as an [Object](./object.md) or [Dictionary](./dictionary.md). NoPoDoFo will always try to +resolve Ref types to their corresponding [Object](./object.md) but in the instance a value can not be resolved an error will be thrown. + +### addKey +Add a new entry to the dictionary, with an NPDFName `k` and a value. If the value is an [Object](./object.md) the object's reference will be +stored instead, for primitive data types a new PoDoFo PdfVariant will be created with the value provided. + +### getKeys +Get all the keys in the dictionary. + +### hasKey +Check if a key exists in the dictionary. Check is not recursive, if you are trying to check a nested dictionary you will need to call this method at +each level. + +### removeKey +Remove an entry from the dictionary. + +### getKeyAs +Get the value of the `k` key out of the dictionary as one of NPDFCoerceKeyType types. If the value can not be cast as the type defined an error will be thrown. + +### clear +Remove all keys from the dictionary. + +### write +Writes the dictionary to disk. Can be useful for debugging. + +### writeSync +Writes the dictionary to disk as a blocking operation. Can be useful for debugging. \ No newline at end of file diff --git a/docs/document.md b/docs/document.md index a629be6..dac0e54 100644 --- a/docs/document.md +++ b/docs/document.md @@ -58,11 +58,37 @@ Document utilizes PoDoFo's load on demand policy. When a PDF is loaded through ` at their first point of access. If an object is never used, it will never be loaded into memory, allowing for the ingestion and modification of large documents with a small memory footprint. +```typescript +class Document extends Base { + constructor() + + password: string + encrypt: Encrypt + readonly trailer: Object + readonly catalog: Object + + load(file: string | Buffer, + opts: { + forUpdate?: boolean, + password?: string + }, + cb: Callback): void + load(file: string | Buffer, cb: Callback): void + splicePages(startIndex: number, count: number): void + insertPages(fromDoc: Document, startIndex: number, count: number): number + write(destination: Callback | string, cb?: Callback): void + getFont(name: string): Font + listFonts(): { id: string, name: string }[] + gc(file: string, pwd: string, output: string, cb: Callback): void + hasSignatures(): boolean + getSignatures(): SignatureField[] +} +``` ## Properties ### catalog -Readonly, returns the Documents catalog object as an IObj. +Readonly, returns the Documents catalog [Object](./object.md). ### trailer diff --git a/spec/test-documents/attachment.pdf b/spec/test-documents/attachment.pdf index 49409c2..858a2fc 100644 Binary files a/spec/test-documents/attachment.pdf and b/spec/test-documents/attachment.pdf differ