DynaPDF Manual - Page 55

Previous Page 54   Index   Next Page 56

Interactive Forms
Page 55 of 839
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.
Data types supported as value of a key are: array, dictionary, name, string, boolean true or false
(case sensitive), null, and number. A JSON string must be enclosed with double quotes.
Example: "This is a string".
In PDF, keys are always defined as name objects. The function converts a key (or name in JSON
nomenclatur) automatically to a name object. However, no such automatic conversion is
possible for values since the function does not interpret the resulting PDF keys and therefore, it
does not know which datatype a key accepts.
In order to output a string as name object add a slash as first charactert to the string, e.g. "Test
name object value" : "/PDFNameObject".
Examples (C/C++):
The examples below show that a JSON string can contain various errors which would not be
accepted by a regular JSON parser:
const char attr[] = "{/BBox[50, 450, 200, 500]/Placement/Inline}";
// Ok
const char attr[] = "/BBox :[50 450 200 500]/Placement/Inline";
// Ok
const char attr[] = "{{{{/BBox :[50 450 200 500]/Placement/Inline";
// Ok
const char attr[] = "/BBox :[50 450 200 500]/Placement/Inline}}}}";
// Ok
const char attr[] = "\"BBox\":[50 450 200 500]\"Placement\"/Inline"; // Ok
const char attr[] = "/BBox,[50 450 200 500]\"Placement\"/Inline";
// Ok
const char attr[] = "/BBox:[50 450 200 500]/Placement/Inline";
// Ok
 

Previous topic: JSON Parser

Next topic: Interactive Forms, Field Appearance