Class PDFNet.SDFDoc
PDFNet.SDFDoc
Constructor Attributes | Constructor Name and Description |
---|---|
PDFNet.SDFDoc(id)
SDFDoc is a low-level document representing a graph of SDF::Obj nodes that
can be used to build higher-level document models such as PDF (Portable Document
Format) or FDF (Forms Document Format).
|
Method Attributes | Method Name and Description |
---|---|
Removes 'marked' flag from all objects in cross reference table.
|
|
Used to create SDF/Cos indirect object.
|
|
createIndirectBool(value)
Used to create SDF/Cos indirect object.
|
|
createIndirectDict(value)
Used to create SDF/Cos indirect object.
|
|
createIndirectName(name)
Used to create SDF/Cos indirect object.
|
|
createIndirectNull(value)
Used to create SDF/Cos indirect object.
|
|
createIndirectNumber(value)
Used to create SDF/Cos indirect object.
|
|
createIndirectStream(value, data_size, filter_chain)
Used to create SDF/Cos indirect object.
|
|
createIndirectStreamFromFilter(data, filter_chain)
|
|
createIndirectString(buf_value)
Used to create SDF/Cos indirect object.
|
|
Used to create SDF/Cos indirect object.
|
|
Copy Constructor
|
|
enableDiskCaching(use_cache_flag)
A document uses a temporary file which is used to cache the contents
of any new stream object created in the document (that is the default behavior).
|
|
Returns document's initial linearization hint stream if it is available.
|
|
Returns document's initial linearization dictionary if it is available.
|
|
getObj(obj_num)
|
|
importObj(obj, deep_copy)
|
|
initSecurityHandler(custom_data)
Initializes document's SecurityHandler.
|
|
initStdSecurityHandler(password, password_sz)
Initializes document's SecurityHandler using the supplied
password.
|
|
initStdSecurityHandlerUString(password)
Initializes document's SecurityHandler using the supplied
password.
|
|
Call this function to determine whether the document is represented in
linearized (fast web view) format.
|
|
lock()
Locks the document to prevent competing threads from accessing the document
at the same time.
|
|
lockRead()
Locks the document to prevent competing write threads (using Lock()) from accessing the document
at the same time.
|
|
This function removes document security.
|
|
saveMemory(flags, header)
[Documentation Not Yet Added]
|
|
saveStream(stream, flags, header)
Saves the document to a stream.
|
|
setSecurityHandler(handler)
The function sets a new SecurityHandler as the current security handler.
|
|
swap(obj_num1, obj_num2)
Sometimes it is desirable to modify all indirect references to a given
indirect object.
|
|
timedLock(milliseconds)
Try locking the document, waiting no longer than specified number of milliseconds.
|
|
timedLockRead(milliseconds)
Try locking the document, waiting no longer than specified number of milliseconds.
|
|
tryLock()
Try locking the document.
|
|
Tries to obtain a read lock the document and returns true if the lock was
successfully acquired
|
|
unlock()
Removes the lock from the document.
|
|
Removes the lock from the document.
|
|
xRefSize()
|
Class Detail
PDFNet.SDFDoc(id)
SDFDoc is a low-level document representing a graph of SDF::Obj nodes that
can be used to build higher-level document models such as PDF (Portable Document
Format) or FDF (Forms Document Format).
SDFDoc brings together document security, document utility methods, and all SDF
objects.
A SDF document can be created from scratch using a default constructor:
SDFDoc mydoc;
Obj trailer = mydoc.GetTrailer();
SDF document can be also created from an existing file (e.g. an external PDF document):
- Parameters:
- id
Method Detail
clearMarks()
Removes 'marked' flag from all objects in cross reference table.
{Obj}
createIndirectArray()
Used to create SDF/Cos indirect object.
Unlike direct objects, indirect objects can be referenced by more than one
object (i.e. indirect objects they can be shared).
- Returns:
- {Obj} A promise that resolves to an object of type: "Obj" (generated documentation)
{Obj}
createIndirectBool(value)
Used to create SDF/Cos indirect object.
Unlike direct objects, indirect objects can be referenced by more than one
object (i.e. indirect objects they can be shared).
- Parameters:
- {boolean} value
- indirect boolean to create.
- Returns:
- {Obj} A promise that resolves to an object of type: "Obj" (generated documentation)
{Obj}
createIndirectDict(value)
Used to create SDF/Cos indirect object.
Unlike direct objects, indirect objects can be referenced by more than one
object (i.e. indirect objects they can be shared).
- Parameters:
- value
- indirect boolean to create.
- Returns:
- {Obj} A promise that resolves to the created indirect object.
{Obj}
createIndirectName(name)
Used to create SDF/Cos indirect object.
Unlike direct objects, indirect objects can be referenced by more than one
object (i.e. indirect objects they can be shared).
- Parameters:
- {string} name
- indirect const char* object to create.
- Returns:
- {Obj} A promise that resolves to an object of type: "Obj" (generated documentation)
{Obj}
createIndirectNull(value)
Used to create SDF/Cos indirect object.
Unlike direct objects, indirect objects can be referenced by more than one
object (i.e. indirect objects they can be shared).
- Parameters:
- value
- indirect boolean to create.
- Returns:
- {Obj} A promise that resolves to the created indirect object.
{Obj}
createIndirectNumber(value)
Used to create SDF/Cos indirect object.
Unlike direct objects, indirect objects can be referenced by more than one
object (i.e. indirect objects they can be shared).
- Parameters:
- {number} value
- indirect boolean to create.
- Returns:
- {Obj} A promise that resolves to the created indirect object.
{Obj}
createIndirectStream(value, data_size, filter_chain)
Used to create SDF/Cos indirect object.
Unlike direct objects, indirect objects can be referenced by more than one
object (i.e. indirect objects they can be shared).
- Parameters:
- {string [Y]} value
- indirect boolean to create.
- {number} data_size
- (generated documentation)
- {Filter} filter_chain
- (generated documentation)
- Returns:
- {Obj} A promise that resolves to the created indirect object.
{Obj}
createIndirectStreamFromFilter(data, filter_chain)
- Parameters:
- {FilterReader} data
- (generated documentation)
- {Filter} filter_chain
- (generated documentation)
- Returns:
- {Obj} A promise that resolves to an object of type: "Obj" (generated documentation)
{Obj}
createIndirectString(buf_value)
Used to create SDF/Cos indirect object.
Unlike direct objects, indirect objects can be referenced by more than one
object (i.e. indirect objects they can be shared).
- Parameters:
- {Array} buf_value
- indirect boolean to create.
- Returns:
- {Obj} A promise that resolves to the created indirect object.
{Obj}
createIndirectStringFromUString(str)
Used to create SDF/Cos indirect object.
Unlike direct objects, indirect objects can be referenced by more than one
object (i.e. indirect objects they can be shared).
- Parameters:
- {string} str
- indirect boolean to create.
- Returns:
- {Obj} A promise that resolves to the created indirect object.
{SDFDoc}
createShallowCopy()
Copy Constructor
- Returns:
- {SDFDoc} A promise that resolves to an object of type: "SDFDoc" (generated documentation)
enableDiskCaching(use_cache_flag)
A document uses a temporary file which is used to cache the contents
of any new stream object created in the document (that is the default behavior).
- Parameters:
- {boolean} use_cache_flag
- true to enable caching, false to disable caching. Use this function to enable or disable this feature dynamically.
{string}
getFileName()
- Returns:
- {string} A promise that resolves to the filename of the document if the document is loaded from disk, or empty string if the document is not yet saved or is loaded from a memory buffer.
{string}
getHeader()
- Returns:
- {string} A promise that resolves to the header string identifying the document version to which the file conforms. For a file conforming to PDF version 1.4, the header should be %PDF-1.4. In general header strings have the following syntax: %AAA-N.n where AAA identifies document specification (such as PDF, FDF, PJTF etc), N is the major version and n is the minor version. The new header string can be set during a full save (see SDFDoc::Save()). For a document that is not serialized the function returns an empty string.
{Obj}
getHintStream()
Returns document's initial linearization hint stream if it is available.
- Returns:
- {Obj} A promise that resolves to the linearization hint stream of the original document or NULL if the hint stream is not available.
{Obj}
getLinearizationDict()
Returns document's initial linearization dictionary if it is available.
- Returns:
- {Obj} A promise that resolves to the linearization dictionary of the original document or NULL if the dictionary is not available.
{Obj}
getObj(obj_num)
- Parameters:
- {number} obj_num
- object number of the object to retrieve.
- Returns:
- {Obj} A promise that resolves to the latest version of the object matching specified object number.
{SecurityHandler}
getSecurityHandler()
- Returns:
- {SecurityHandler} A promise that resolves to currently selected SecurityHandler.
{Obj}
getTrailer()
- Returns:
- {Obj} A promise that resolves to A dictionary representing the root of the document (i.e. a document trailer dictionary)
{Obj}
importObj(obj, deep_copy)
- Parameters:
- {Obj} obj
- an object to import.
- {boolean} deep_copy
- a boolean indicating whether to perform a deep or shallow copy. In case of shallow copy all indirect references will be set to null. If the object belongs to a document the function will perform deep or shallow clone depending whether deep_copy flag was specified. If the object does not belong to any document ImportObj does not take the object ownership. ImportObj copies the source object and it is users responsibility to delete free objects.
- Returns:
- {Obj} A promise that resolves to a pointer to the root indirect object in this document
{boolean}
initSecurityHandler(custom_data)
Initializes document's SecurityHandler. This version of InitSecurityHandler()
works with Standard and Custom PDF security and can be used in situations where
the password is obtained dynamically via user feedback. See EncTest sample for
example code.
This function should be called immediately after an encrypted
document is opened. The function does not have any side effects on
documents that are not encrypted.
If the security handler was successfully initialized it can be later obtained
using GetSecurityHandler() method.
- Parameters:
- {UNKNOWNTYPE} custom_data
- An optional parameter used to specify custom data that should be passed in SecurityHandler::Initialize() callback.
- Returns:
- {boolean} A promise that resolves to true if the SecurityHandler was successfully initialized (this may include authentication data collection, verification etc.), false otherwise.
{boolean}
initStdSecurityHandler(password, password_sz)
Initializes document's SecurityHandler using the supplied
password. This version of InitSecurityHandler() assumes that
document uses Standard security and that a password is specified
directly.
This function should be called immediately after an encrypted
document is opened. The function does not have any side effects on
documents that are not encrypted.
If the security handler was successfully initialized, it can be later
obtained using GetSecurityHandler() method.
- Parameters:
- {string} password
- Specifies the password used to open the document without any user feedback. If you would like to dynamically obtain the password, you need to derive a custom class from StdSecurityHandler() and use InitSecurityHandler() without any parameters. See EncTest sample for example code.
- {number} password_sz
- An optional parameter used to specify the size of the password buffer, in bytes. If the 'password_sz' is 0, or if the parameter is not specified, the function assumes that the string is null terminated.
- Returns:
- {boolean} A promise that resolves to true if the given password successfully unlocked the document, false otherwise.
{boolean}
initStdSecurityHandlerUString(password)
Initializes document's SecurityHandler using the supplied
password. This version of InitSecurityHandler() assumes that
document uses Standard security and that a password is specified
directly.
This function should be called immediately after an encrypted
document is opened. The function does not have any side effects on
documents that are not encrypted.
If the security handler was successfully initialized, it can be later
obtained using GetSecurityHandler() method.
- Parameters:
- {string} password
- Specifies the password used to open the document without any user feedback. If you would like to dynamically obtain the password, you need to derive a custom class from StdSecurityHandler() and use InitSecurityHandler() without any parameters. See EncTest sample for example code.
- Returns:
- {boolean} A promise that resolves to true if the given password successfully unlocked the document, false otherwise.
{boolean}
isEncrypted()
- Returns:
- {boolean} A promise that resolves to true if the document is/was originally encrypted false otherwise.
{boolean}
isFullSaveRequired()
- Returns:
- {boolean} A promise that resolves to true if the document requires full save.
{boolean}
isLinearized()
Call this function to determine whether the document is represented in
linearized (fast web view) format.
- Returns:
- {boolean} A promise that resolves to true if document is stored in fast web view format, false otherwise.
{boolean}
isModified()
- Returns:
- {boolean} A promise that resolves to true if document was modified, false otherwise
lock()
Locks the document to prevent competing threads from accessing the document
at the same time. Threads attempting to access the document will wait in
suspended state until the thread that owns the lock calls doc.Unlock().
lockRead()
Locks the document to prevent competing write threads (using Lock()) from accessing the document
at the same time. Other reader threads however, will be allowed to access the document.
Threads attempting to obtain write access to the document will wait in
suspended state until the thread that owns the lock calls doc.UnlockRead().
Note: To avoid deadlocks obtaining a write lock while holding
a read lock is not permitted and will throw an exception. If this situation is encountered
please either unlock the read lock before the write lock is obtained
or acquire a write lock (rather than read lock) in the first place.
removeSecurity()
This function removes document security.
saveMemory(flags, header)
[Documentation Not Yet Added]
- Parameters:
- {string} flags
- (generated documentation)
- {number} header
- (generated documentation)
saveStream(stream, flags, header)
Saves the document to a stream.
- Parameters:
- {Filter} stream
- The output stream where to write data.
- {number} flags
- A bit field composed of an OR of the SDFDoc::SaveOptions values.
- {string} header
- File header. A new file header is set only during full save. See also GetHeader()
setSecurityHandler(handler)
The function sets a new SecurityHandler as the current security handler.
- Parameters:
- {SecurityHandler} handler
- new SecurityHandler
swap(obj_num1, obj_num2)
Sometimes it is desirable to modify all indirect references to a given
indirect object. It would be inefficient to manually search for all
indirect references to a given indirect object.
A more efficient and less error prone method is to replace the indirect
object in the cross reference table with a new object. This way the object
that is referred to is modified (or replaced) and indirect references do
not have to be changed.
- Parameters:
- {number} obj_num1
- object number of first object to be swapped.
- {number} obj_num2
- object number of second object to be swapped.
{boolean}
timedLock(milliseconds)
Try locking the document, waiting no longer than specified number of milliseconds.
- Parameters:
- {number} milliseconds
- max number of milliseconds to wait for the document to lock
- Returns:
- {boolean} A promise that resolves to true if the document is locked for multi-threaded access, false otherwise.
{boolean}
timedLockRead(milliseconds)
Try locking the document, waiting no longer than specified number of milliseconds.
- Parameters:
- {number} milliseconds
- max number of milliseconds to wait for the document to lock
- Returns:
- {boolean} A promise that resolves to true if the document is locked for multi-threaded access, false otherwise.
{[ERROR]}
tryLock()
Try locking the document.
- Returns:
- {[ERROR]} true if the document is locked for multi-threaded access, false otherwise.
{[ERROR]}
tryLockRead()
Tries to obtain a read lock the document and returns true if the lock was
successfully acquired
- Returns:
- {[ERROR]} true if the document is locked for multi-threaded access, false otherwise.
unlock()
Removes the lock from the document.
unlockRead()
Removes the lock from the document.
{number}
xRefSize()
- Returns:
- {number} A promise that resolves to The size of cross reference table