DynaPDF Manual - Page 131

Previous Page 130   Index   Next Page 132

Function Reference
Page 131 of 839
How to create DPM?
Since DPM can contain all basic data types that PDF supports, we need an exchange format that is
easy to create and that supports very similar data types. The exchange format that matches these
requirements is called JSON.
The JSON parser in DynaPDF supports a few extensions to make the definition of DPM as easy as
possible.
Differences in comparison to regular JSON grammar:
A JSON string begins normally with a left brace ({) and ends with a right brace (}). This outer
left / right brace pair can be omitted.
Key / value pairs must normally be delimited by a colon (:). The delimiting colon can be
omitted.
Array values must normally be delimited by a comma (,). The delimiting comma can be
omitted if the bounds of the value can be detected by whitespace or starting character of the
next object.
Example (C/C++):
const char dpm[] = "\"TestArray\"[1/2\"3\"4 5]";
Result:
/DPM<</TestArray[1/2(3)4 5]...>>
The first value of the array is the number 1, the second is a name object with the value "2",
the third value is the string "3", the fourth is the number 4, and the fifths is the number 5.
Extension: A Solidus (/) begins a PDF Name object. The solidus is not part of the name but is
a prefix indicating what follows is a sequence of characters representing a name object. A
name object supports character codes between 33..126 inclusive. Any character outside this
range must be written as two digit hexadecimal code, preceded by a number sign (#), e.g.
/This#20is#20a#20name#20with#20spaces. Note that a number sign in a name object must be
written as hexadecimal code too, since the number sign is treated as an escape character. The
de-escaped string is interpreted as UTF-8 Unicode string.
A character code < 33, { (left brace), } (right brace), [ (left bracket), ] (right bracket), , (comma),
: (colon), or " (double quotes) terminate a name object. If one of these characters should be
part of a name object then write it as two digit hexadecimal code preceded by a number sign
(#).
A left brace ({) creates a PDF dictionary and a right brace (}) finishes or closes it.
A left bracked ([) creates an array and a right bracked (]) finishes or closes it.
 

Previous topic: AddDPartNode, Document Part Metadata (DPM)

Next topic: AddFieldToFormAction, AddFieldToHideAction